Hello, I'm new nere and very much a beginner with python. I'm trying to make a blackgame program not to play but to test strategies, like I used to play this wristwatch game and always double at 12 and surrender at 17. Which is bad strategy but I swore it worked for that watch game. It seems I am stuck in a loop. (starts and doesn't stop)
from random import choice as rc def total(hand): aces = hand.count(11) t = sum(hand) if t > 21 and aces > 0: while aces > 0 and t > 21: t -= 10 aces -= 1 return t cards = [2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11] cwin = 0 # computer win counter pwin = 0 # player win counter while True: player =  player.append(rc(cards)) player.append(rc(cards)) pbust = False # player busted flag cbust = False # computer busted flag while True: # loop for the player tp = total(player) if tp > 21: pbust = True else: if tp < 16: player.append(rc(cards)) else: break while True: comp =  comp.append(rc(cards)) comp.append(rc(cards)) while True: tc = total(comp) if tc < 17: comp.append(rc(cards)) else: break if tc > 21: cbust = True if pbust == False: pwin += 1 elif tc > tp: cwin += 1 elif tc == tp: pwin += 0 elif tp > tc: if pbust == False: pwin += 1 elif cbust == False: cwin += 1 print "pwin"
I want it to play one hand (for now). Then I could put in the conditions for double which would +2 to counter if win and surrender -.5 iterate it. I ididnt really write this but I had to figure out the indentation, so I dont know if it is right. I wish I knew who did write this so I could thank them maybe paypal them some money or something.
One more thing, I want it to print the value for pwin not the letters "pwin" which I would think is going to happen. Do you know I I would do this? Do you see where I missed a break and the loop is infinite? Thanks for looking.