【发布时间】:2020-03-06 11:48:20
【问题描述】:
我正在为学校作业编写二十一点游戏,我试图了解结构/逻辑的某些部分。
目前,我在为闲家/庄家手牌汇总随机生成的牌时遇到问题。此外,我在结构方面遇到问题,并在 main() 中调用我的函数。
import random
Dealer_Chips = 500
Player_Chips = 500
Pot = 0
deck = {'Two': 2, 'Three' : 3, 'Four' : 4, 'Five' : 5, 'Six' : 6, 'Seven' : 7, 'Eight' : 8, 'Nine' : 9, 'Jack' : 10, 'Queen' :10, 'King' : 10, 'Ace' : 11}
Player_Hand = [random.choice(list(deck)), random.choice(list(deck))] #Creates Player hand
Dealer_Hand = [random.choice(list(deck)), random.choice(list(deck))] #Creats Dealer Hand
Player_Score = 0
Dealer_Score = 0
enter code here
def Ace():
if Player_Hand == 'Ace':
input("You drew an Ace, Please choose whether the Ace is a 1 or 11")
def Hit():
Player_Hand + random.choice(list(deck))
print("You chose to Hit, Your hand is", Player_Hand)
def Stay():
print ("stay")
def Bet():
input("Please place a bet. Bets can be either 5, 10, 25, 50")
if input == 5:
Pot + 5
if input == 10:
Pot + 10
if input == 25:
Pot + 25
if input == 50:
Pot + 50
def Winner():
print("Congratulations, you win!")
Player_Chips + Pot
def Main():
print("Welcome to Blackjack!")
print("Your Hand is", Player_Hand, "Your Chip Count is", Player_Chips)
input == Bet()
input("Would you like to hit or stay? Enter H to hit, or S to stay")
if input == "H":
Hit()
if input == "S":
Stay()
Main()
【问题讨论】:
-
您能否提供您正在尝试做的事情以及出了什么问题?您的代码的一些输出也将有助于调试
-
很抱歉没有添加输出。这是正在发生的事情。 # 欢迎来到二十一点!您的手牌是 ['Seven', 'Ace'] 您的筹码数是 500 请下注。赌注可以是 5、10、25、50 你想打还是留下?输入 H 击中,或输入 S 停留。我输入H,游戏结束。进程以退出代码 0 结束
标签: python python-3.x list pygame blackjack