This commit is contained in:
Andrzej Preibisz 2023-01-31 22:26:19 +01:00
parent 30924a6260
commit 5f9a11c2fc

View File

@ -58,6 +58,17 @@ def dealer(hand: list, shoe: iter) -> int:
evaluation = cards_eval(hand)
return max(evaluation)
def count_highlow(hand: list) -> int:
highlow = 0
low_cards = [1, 2, 3, 4, 5, 6, 7]
for card in hand:
if card in low_cards:
highlow -= 1
elif card == 10:
highlow += 1
return highlow
def AI(hand: list, face_up: str, losses_in_row: int) -> str:
#TODO: add fuzzy logic
"""Fuzzy AI
@ -70,21 +81,21 @@ def AI(hand: list, face_up: str, losses_in_row: int) -> str:
Returns:
list: player decision
"""
### temp
# if face_up == 'ace':
# return 'surrender'
# else:
evaluation = max(cards_eval(hand))
decision = getStartDecision(evaluation, losses_in_row)
print(evaluation, decision)
if evaluation == 11:
return 'double down'
if evaluation <= 17:
return 'hit'
else:
return 'stand'
### temp
cards_count = len(hand)
evaluation = cards_eval(hand)
if len(evaluation) != 1:
evaluation = evaluation[1]
else:
evaluation = evaluation[0]
decision = ''
if 'ace' in hand:
decision = getSoftHandDecision(face_up, evaluation, cards_count)
else:
decision = getHardHandDecision(face_up, evaluation, cards_count)
breakpoint()
return decision
def show_game_state(player_hand: list, dealer_hand: list, decision: str='') -> None:
"""Print dealer and player card values and player decision