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

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

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

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

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

 

# -*- coding: utf-8 -*-
"""
Created on Thu Jul 11 14:59:10 2019

@author: leslie lee
"""

import random

suits=['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。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值