dealer_blackjack = False
    if ("ace" in player_hand) and (10 in player_hand):
        player_blackjack = True
    else:
        player_blackjack = False

    if (dealer_blackjack == True) and (player_blackjack == True):
        total_return += 0.0
    elif (dealer_blackjack == True) and (player_blackjack == False):
        total_return += -1.0
    elif (dealer_blackjack == False) and (player_blackjack == True):
        total_return += 1.5
    else:

        score = play_a_hand_player(player_hand, dealer_show_card)
        dealer_score = id.play_a_hand_dealer([dealer_show_card, id.deck(random.randint(1, 13))])
        if dealer_score == "bust":
            dealer_score = 0
        format_score = ist.make_single_list(score)
        for element in format_score:
            if element == 22:
                total_return += 1.5
            elif element == 0:
                total_return += -1.0
            elif element > dealer_score:
                total_return += 1.0
            elif element == dealer_score:
                total_return += 0.0
            else:
                total_return += -1.0
Esempio n. 2
0
        soft = False

    return (score,soft)

return_away_no_split = np.zeros((10,13))

l = 0
number_of_trials = 10000

#play number_of_trials hands ber [i][j] index and populate array
for card_total in (4,6,8,10,12,14,16,18,20,'ace'):
    for j in range(13):
        for x in range(number_of_trials):
            total_return = 0.0
            dealer_hand = [id.deck(j+1),id.deck(random.randint(1,13))]
            dealer_score = id.play_a_hand_dealer(dealer_hand)
            if dealer_score == 'bust':
                dealer_score = 0

            if card_total == 'ace':
                score = 12
                issoft = True

            else:
                score = card_total
                issoft = False

            if (10 in dealer_hand) and ('ace' in dealer_hand):
                dealer_blackjack = True
            else:
                dealer_blackjack = False