You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
% If the player's sum is larger than 21, he may hold one or two aces.
if player_sum > 21:
assert player_sum == 22
# last card must be ace
player_sum -= 10
else:
usable_ace_player |= (1 == card)
Question: in the "if" part of the above code, when last card must be ace, why do you not set "usable_ace_player |= (1 == card)"?
The text was updated successfully, but these errors were encountered:
eatam
changed the title
Unclear code section in Blackjack example
it will be better to write more comments for the code section in Blackjack example
Feb 7, 2022
eatam
changed the title
it will be better to write more comments for the code section in Blackjack example
It will be better to write more comments (to make the steps and purposes) for the code in Blackjack example
Feb 7, 2022
eatam
changed the title
It will be better to write more comments (to make the steps and purposes) for the code in Blackjack example
It will be better to write more comments (to make the steps and purposes clearer) for the code in Blackjack example
Feb 7, 2022
eatam
changed the title
It will be better to write more comments (to make the steps and purposes clearer) for the code in Blackjack example
Unclear point for the code in Blackjack example
Feb 7, 2022
The description of the example 5.1 of the book states:
If the player holds an ace that he could count as 11 without going bust, then the ace is said to be usable.
Therefore, if the condition player_sum > 21 is satisfied, this means that it came out one of the following combinations (otherwise we would be outside of the while loop):
ace + ace
card_1 + card_2 + ace, where card_1 + card_2 = 11
In both cases, the sum is equal to 22 and the ace (the second one for the first case) is not usable since the player goes bust and therefore it is correct not to set "usable_ace_player |= (1 == card)".
Notice that in the first case the first ace leads to usable_ace_player = True since it is actually usable.
Question: in the "if" part of the above code, when last card must be ace, why do you not set "usable_ace_player |= (1 == card)"?
The text was updated successfully, but these errors were encountered: