Я хотел бы поиграть в покерную программу 10 раз и посмотреть, сколько денег делает программа. Это результат, который я получил, а затем я должен запустить его снова, но программа не напоминает сумму денег, заработанную в предыдущем раунде. У вас есть какие-то предложения?Завершение вывода покерной программы
Dealer has:
D9
Player1, you have:
['HK', 'DQ']
The amount of money player has won so far
0
What would you like to do? H: Hit me, S: Stand? S
Player wins with 20points
Dealer Busted and has: ['D9', 'C3', 'S5']or17points
Player has won : 2euros
Процесс закончил с кодом выхода 0
И я хотел бы иметь дополнительную строку с Total заработанных денег на дне, и программа снова спрашивает меня вопрос, если я хотел бы сделать это снова. С чего начать?
Код
from random import shuffle
def card():
card = []
for speci in ['H', 'D', 'S', 'C']:
for number in ['A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K']:
card.append(speci+number)
shuffle(card)
return card
def pointcount(mycards):
counting = 0
acecount = 0
for i in mycards:
if(i[1] == 'J' or i[1] == 'Q' or i[1] == 'K' or i[1] == 'T'):
counting += 10
elif(i[1] != 'A'):
counting += int(i[1])
else:
acecount += 1
if(acecount == 1 and counting >= 10):
counting += 11
elif(acecount != 0):
counting += 1
return counting
def createplayinghands(mydeck):
dealerhand = []
playerhand = []
dealerhand.append(mydeck.pop())
dealerhand.append(mydeck.pop())
playerhand.append(mydeck.pop())
playerhand.append(mydeck.pop())
while(pointcount(dealerhand) <= 16):
dealerhand.append(mydeck.pop())
return [dealerhand, playerhand]
game = ""
mycard = card()
hands = createplayinghands(mycard)
dealer = hands[0]
player = hands[1]
money = 0
while(game != "exit"):
dealercount = pointcount(dealer)
playercount = pointcount(player)
print("Dealer has:")
print(dealer[0])
print("Player1, you have:")
print(player)
print("The amount of money player has won so far")
print(money)
if(playercount == 21):
money += 3
print("Blackjack Player wins")
print("Player has won: " + str(money) + "euros")
break
elif(playercount > 21):
money += 0
print("player Busts with " + str(playercount) + "points")
print("Player has won: " + str(money) + "euros")
break
elif(dealercount > 21):
print("Dealer Busts with " + str(dealercount) + "points")
print("Player has won: " + str(money) + "euros")
break
game = input("What would you like to do? H: Hit me, S: Stand? ")
if(game == 'H'):
player.append(mycard.pop())
elif(dealercount > 21):
money += 2
print("Player wins with " + str(playercount) + "points")
print("Dealer has: " + str(dealer) + "or" + str(dealercount) + "points")
print("Player has won : " + str(money) + "euros")
break
elif(playercount > dealercount):
money += 2
print("Player wins with " + str(playercount) + "points")
print("Dealer Busted and has: " + str(dealer) + "or" + str(dealercount) + "points")
print("Player has won : " + str(money) + "euros")
break
elif(playercount == dealercount):
money += 2
print("Tie Player with " + str(playercount) + "points")
print("Dealer has: " + str(dealer) + " or " + str(dealercount) + "poi nts")
print("Player has won : " + str(money) + "euros")
break
else:
money += 0
print("Dealer wins")
print("Dealer has: " + str(dealer) + "or" + str(dealercount) + "points")
print("Player has won : " + str(money) + "euros")
break
Вы можете начать с показа своих попыток. –
Какой у вас текущий код? Отправьте свою текущую попытку кода здесь, и мы можем помочь выяснить, что вы делаете неправильно. – SashaZd
Этот вопрос слишком широк и на него нельзя ответить без реализации всей программы ... пожалуйста, опубликуйте свой код и покажите нам, что вы пробовали, и где вы застряли – alfasin