python抽样不同花色纸牌,Python:如何为纸牌游戏绘制一组新的不同的牌?

我正在寻找一些关于一个简单的纸牌游戏的帮助。前提是:一副牌中洗牌的30张牌,每副牌的颜色为红色、蓝色和黄色,每副牌的数字为1-10

2名玩家从这副牌堆的顶部收到一张牌

某些颜色会胜过另一种颜色

获胜者将得到两张扑克牌

这个过程会重复,直到牌堆中没有矿石卡。在

我的问题是,一旦第一次出牌结束,我就想不出一种方法来抽新牌。我的代码会调用已经玩过的牌(这会导致错误)。有没有什么有效的方法可以让我在使用代码的同时抽到新卡?谢谢。在import random

Deck = ['R1', 'R2', 'R3', 'R4', 'R5', 'R6', 'R7', 'R8', 'R9', 'R10', 'Y1', 'Y2', 'Y3', 'Y4', 'Y5', 'Y6', 'Y7', 'Y8', 'Y9', 'Y10', 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B9', 'B10']

random.shuffle(Deck)

print(Deck)

Player1Card = Deck[0]

print("Player One, Your Card Is {0}" .format(Deck[0]))

Player2Card = Deck[1]

print("Player Two, Your Card Is {0}" .format(Deck[1]))

PlayerOneScore = 0

PlayerTwoScore = 0

GameCount = 0

PlayerOneCardList = list()

PlayerTwoCardList = list()

1 < 2

2 < 3

3 < 4

4 < 5

5 < 6

7 < 8

8 < 9

9 < 10

while GameCount == 0:

if "R" in Player1Card and "B" in Player2Card:

print("Player One Wins")

PlayerOneScore = PlayerOneScore+2

print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))

PlayerOneCardList.append(Player1Card)

PlayerOneCardList.append(Player2Card)

print("Player 1, These Are Your Currently Held Cards:")

print(PlayerOneCardList)

print("Player 2, These Are Your Currently Held Cards:")

print(PlayerTwoCardList)

Deck.remove(Player1Card)

Deck.remove(Player2Card)

elif "R" in Player2Card and "B" in Player1Card:

print("Player Two Wins")

PlayerTwoScore = PlayerTwoScore+2

print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))

elif "B" in Player1Card and "Y" in Player2Card:

print("Player One Wins")

PlayerOneScore = PlayerOneScore+2

print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))

elif "B" in Player2Card and "Y" in Player1Card:

print("Player Two Wins")

PlayerTwoScore = PlayerTwoScore+2

print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))

elif "Y" in Player1Card and "R" in Player2Card:

print("Player One Wins")

PlayerOneScore = PlayerOneScore+2

print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))

elif "Y" in Player2Card and "R" in Player1Card:

print("Player Two Wins")

PlayerTwoScore = PlayerTwoScore+2

print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))

elif "Y" in Player1Card and "Y" in Player2Card:

if Player1Card > Player2Card:

print("Player One Wins")

PlayerOneScore = PlayerOneScore+2

print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))

elif Player1Card < Player2Card:

print("Player Two Wins")

PlayerTwoScore = PlayerTwoScore+2

print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))

elif "B" in Player1Card and "B" in Player2Card:

if Player1Card > Player2Card:

print("Player One Wins")

PlayerOneScore = PlayerOneScore+2

print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))

elif Player1Card < Player2Card:

print("Player Two Wins")

PlayerTwoScore = PlayerTwoScore+2

print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))

elif "R" in Player1Card and "R" in Player2Card:

if Player1Card > Player2Card:

print("Player One Wins")

PlayerOneScore = PlayerOneScore+2

print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))

elif Player1Card < Player2Card:

print("Player Two Wins")

PlayerTwoScore = PlayerTwoScore+2

print("Player One, your score is {0} and Player Two, your score is {1}" . format(PlayerOneScore, PlayerTwoScore))

if PlayerOneScore + PlayerTwoScore == 30:

if PlayerOneScore > PlayerTwoScore:

print("Player One Wins")

print("The game is over")

gamecount = 1

elif PlayerTwoScore > PlayerOneScore:

print("Player Two Wins")

print("The game is over")

gamecount = 1

else:

gamecont1 = input("Would you like to continue the game Y for yes or N for no?")

if gamecont1 == "Y" or "y":

gamecont = 0

else:

gamecont = 1

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值