I'm trying to program basic black jack strategy. I would like for my program to return the proper move depending on the dealer's up card and the players 2 cards from the start of the game. I have put together a simple function to handle the player cards that are being passed in, inside a function to handle the dealer card and the player cards.
def player_has(card_sets, player_cards):
for card_set in card_sets:
if (card_set[0] or card_set[1]) in player_cards:
return True
return False
def get_best_move(player_cards, dealer_card):
move = ''
if dealer_card == 2 or dealer_card == 3 or dealer_card == 4 and \
player_has([[2, 2], [3, 3], [6, 6], [7, 7], [8, 8], [9, 9], [11, 11]], player_cards):
print('split')
elif dealer_card == 2 or dealer_card == 3 or dealer_card == 4 and player_has([[4, 4]], player_cards):
print('Hit')
elif dealer_card == 2 or dealer_card == 3 or dealer_card == 4 and player_has([[5, 5]], player_cards):
print('Double Down')
elif dealer_card == 2 or dealer_card == 3 or dealer_card == 4 and player_has([[10, 10]], player_cards):
print('Stand')
print(move)
return move
_player_cards = [10, 10]
_dealer_card = 3
get_best_move(_player_cards, _dealer_card)
The problem is that this test should return the elif statement with the values [10, 10] in them, or print('stand'). But instead it is returning the if statement at the top that does not include the combination of player cards 10 and 10.
Aucun commentaire:
Enregistrer un commentaire