Fix stand

This commit is contained in:
Andrzej Preibisz 2023-02-02 01:14:41 +01:00
parent dfca353b2a
commit bfad9cbae2

View File

@ -95,6 +95,7 @@ def AI(hand: list, face_up: str, losses_in_row: int) -> str:
is_pair = any([hand.count(val) > 1 for val in vals])
decision = ''
decision = getDecision(face_up, hand, is_pair)
print(decision)
return decision
def show_game_state(player_hand: list, dealer_hand: list, splited: bool, decision: str='') -> None:
@ -141,12 +142,13 @@ def blackjack(shoe: iter, dealer_hand: list=[], player_hand: list=[], bet: int=1
dealer_value = dealer(dealer_hand, shoe)
decision = ''
while decision != 'stand' or decision != 'surrender':
while decision not in ['stand', 'surrender']:
decision = AI(player_hand, face_up, losses_in_row)
show_game_state(player_hand, [face_up], splited, decision)
if decision == 'hit':
player_hand.append(next(shoe))
elif decision == 'double down':
# breakpoint()
bet *= 2
player_hand.append(next(shoe))
elif decision == 'split':
@ -158,9 +160,9 @@ def blackjack(shoe: iter, dealer_hand: list=[], player_hand: list=[], bet: int=1
elif decision == 'surrender':
break
elif decision == 'stand':
dealer_hand.append(next(shoe))
dealer_value = dealer(dealer_hand, shoe)
#dealer_hand.append(next(shoe))
#dealer_value = dealer(dealer_hand, shoe)
break
player_value = max(cards_eval(player_hand))
show_game_state(player_hand, dealer_hand, splited)