Skip to content

Instantly share code, notes, and snippets.

@mingrammer
Last active August 18, 2018 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mingrammer/3eeb0a3bcec3826a078875f6fad0abfd to your computer and use it in GitHub Desktop.
Save mingrammer/3eeb0a3bcec3826a078875f6fad0abfd to your computer and use it in GitHub Desktop.
pycon-2018-banksalad-holdem
from typing import List
from .core.cards import Card
from .core.madehands import evaluate
from .player import Other
def bet(
my_chips: int,
my_cards: List[Card],
bet_players: List[Other],
betting_players: List[Other],
community_cards: List[Card],
min_bet_amt: int,
max_bet_amt: int,
total_bet_amt: int
) -> int:
made_hand = evaluate(my_cards, community_cards)[0].value
if len(community_cards) >= 4:
if made_hand >= 8:
return my_chips
if made_hand >= 6:
return min(my_chips, max_bet_amt)
if made_hand >= 4:
return max(min(my_chips, max_bet_amt, max([p.bet_amt for p in bet_players])), min_bet_amt)
if made_hand >= 3:
return min(my_chips, min_bet_amt)
return 0
return min_bet_amt if my_chips >= min_bet_amt else 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment