Skip to content

Instantly share code, notes, and snippets.

@marcosan93
Created September 6, 2019 21:30
Show Gist options
  • Select an option

  • Save marcosan93/550f4643980a0b696f2cf4bf5477f770 to your computer and use it in GitHub Desktop.

Select an option

Save marcosan93/550f4643980a0b696f2cf4bf5477f770 to your computer and use it in GitHub Desktop.
def player_move(your_hand, limit, true_cnt, dealer_hand):
"""
Chooses 'hit' or 'stay' depending on the limit set and count
"""
dtotal = hand_total(dealer_hand[:1])
# Meaning there are plenty of face cards left
if true_cnt > 0:
if hand_total(your_hand) >= limit:
return 'stay'
elif hand_total(your_hand) < limit:
return 'hit'
elif dtotal >= 10:
return 'stay'
# Meaning there are plenty of low cards left: < 6 value
elif true_cnt < 0:
if hand_total(your_hand) <= limit:
return 'hit'
elif hand_total(your_hand) > limit:
return 'stay'
elif dtotal < 10:
return 'hit'
# Meaning the count is neutral so play a basic strategy
else:
if hand_total(your_hand) >= 17:
return 'stay'
elif hand_total(your_hand) < 17:
return 'hit'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment