Skip to content

Commit

Permalink
Fix a bug in BlackJack, thanks @Huixxi
Browse files Browse the repository at this point in the history
  • Loading branch information
ShangtongZhang committed May 10, 2019
1 parent d9bd574 commit dec0535
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion chapter05/blackjack.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ def play(policy_player, initial_state=None, initial_action=None):
# generate a random initial state

# initialize cards of player
cards = []
while player_sum < 12:
# if sum of player is less than 12, always hit
card = get_card()
cards.append(card)
player_sum += card_value(card)
usable_ace_player = (card == 1)
usable_ace_player = (1 in cards)

# Always use an ace as 11, unless there are two.
# If the player's sum is larger than 21, he must hold two aces.
Expand Down
Binary file modified images/figure_5_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/figure_5_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified images/figure_5_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dec0535

Please sign in to comment.