jj斗地主中pk赛中的败局
比较统一的规律为
炸(10以内)
王
三(A/2) 不同时出现
以上内容出现的牌数在0/3/5
断点 位置(3-13)随机挑3个
现进行模仿
import numpy as np import random as random # 构建牌池 pool_1=[1,2,3,4,5,6,7,8,9,10,11,12,13] pool=np.repeat(pool_1,4).tolist() # 选择顶牌是那种方式 ## 0 炸 1给单王 2给三个 top_card=np.random.choice([0,1,2],1,replace=False) ## 炸的处理 if top_card==0: boom=np.random.choice([1,2,3,4,5,6,7,8,9,10],1,replace=False) gamer1=[boom]*4 #玩家手牌增加炸牌 pool_1.remove(boom) elif top_card==1: boom=np.random.choice([14,15],1,replace=False).tolist() gamer1=boom else: boom=np.random.choice([12,13],1,replace=False) gamer1=[boom]*3#乘三可以考虑 pool_1.remove(boom) # 选择断点 break_card=np.random.choice(pool_1,3,replace=False).tolist()#3的数量可以修改 for bc in break_card: pool_1.remove(bc) ## 开始抽牌 need=17-len(gamer1)#需要抽取的数量 pool_last=np.repeat(pool_1,2) gamer1_puls=np.random.choice(pool_last,need,replace=False).tolist() if type(gamer1)==np.array: gamer1.tolist() else: pass ## 合并 for puls in gamer1_puls: gamer1.append(puls) # 剩余牌数 pool=np.repeat([1,2,3,4,5,6,7,8,9,10,11,12,13],4).tolist() pool.append(14) pool.append(15) for used_card in gamer1: pool.remove(used_card) ## 分发牌数 random.shuffle(pool) gamers=random.sample(pool,34) gamer2=gamers[0:17] gamer3=gamers[17:34] gamer1.sort() gamer2.sort() gamer3.sort() print(gamer1,len(gamer1)) print(gamer2,len(gamer2)) print(gamer3,len(gamer3)) for hand_card2 in gamer2: pool.remove(hand_card2) for hand_card3 in gamer3: pool.remove(hand_card3) print(pool)
原文地址:https://www.cnblogs.com/yuvejxke/p/12679462.html
时间: 2024-10-06 11:13:12