diff --git a/cards.py b/cards.py index 430737b..df21949 100644 --- a/cards.py +++ b/cards.py @@ -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