python 编写一个港式梭哈,发牌时的程序

 港式梭哈共28张牌,每次发牌前需要将牌打乱。

我了解的发牌顺序是,给每个玩家发两张,然后每人再一人一张,直至发够五张为止。

所以我发牌的顺序是基于我了解的玩法编写的。

当然我不是计算机专业的,写出来的代码可能比较麻烦。

 

# -*- coding: utf-8 -*-
"""
Created on Thu Jul 11 14:59:10 2019@author: leslie lee
"""import randomsuits=['Club','Diamond','Spade','Heart']
ranks=['8','9','T','J','Q','K','A']def init_hands():"""将28张牌混合好,并发给两个玩家"""hands=[]for rank in ranks:for suit in suits:hands.append('{0} {1}'.format(rank,suit))    random.shuffle(hands)        """将牌发给玩家"""player1=[]player2=[]player1.append(hands[0])player1.append(hands[1])player1.append(hands[4])player1.append(hands[6])player1.append(hands[8]) player2.append(hands[2])player2.append(hands[3])player2.append(hands[5])player2.append(hands[7])player2.append(hands[9])#print(hands)#print(player1)#print(player2)return player1,player2

如要使用程序,请加上我的名字 leslie lee。


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部