diff --git a/python_skeleton/player.py b/python_skeleton/player.py index 846cedb..3095014 100644 --- a/python_skeleton/player.py +++ b/python_skeleton/player.py @@ -30,8 +30,9 @@ def __init__(self): self.hole_eval = helper.create_hole_table() self.auction_win_probs = (0,0) # with auction, without auction self.won = False + self.opp_fold_cnt = (0, 1) # Opponent opportunites to fold self.cheese = False - + def handle_new_round(self, game_state, round_state, active): ''' Called when a new round starts. Called NUM_ROUNDS times. @@ -71,6 +72,16 @@ def handle_round_over(self, game_state, terminal_state, active): street = previous_state.street # 0, 3, 4, or 5 representing when this round ended my_cards = previous_state.hands[active] # your cards opp_cards = previous_state.hands[1-active] # opponent's cards or [] if not revealed + + # if the game ended preflop and the opponent didn't contribute anything, we count as fold + # TODO: Check logic/math here + if (street == 0 + and ((previous_state.pips[1 - active] == 2 and not bool(active)) + or (previous_state.pips[1 - active] == 1 and bool(active)))): + if my_delta == 2: + self.opp_fold_cnt = (self.opp_fold_cnt[0] + 1, self.opp_fold_cnt[1] + 1) + elif STARTING_STACK - previous_state.stacks[1-active] > 2: + self.opp_fold_cnt = (self.opp_fold_cnt[0], self.opp_fold_cnt[1] + 1) pass def get_action(self, game_state, round_state, active): @@ -102,10 +113,27 @@ def get_action(self, game_state, round_state, active): opp_contribution = STARTING_STACK - opp_stack # the number of chips your opponent has contributed to the pot pot = my_contribution + opp_contribution + # Expected value from not playing + current_opp_fold_pct = self.opp_fold_cnt[0] / self.opp_fold_cnt[1] + passive_EV = (1.5 * (current_opp_fold_pct) - 3 * (1 - current_opp_fold_pct)) * (1000 - game_state.round_num) + + print("Opp fold rate", current_opp_fold_pct) + print("Expected passive EV", passive_EV) + if self.won: if FoldAction in legal_actions: return FoldAction() return CheckAction() + # Cheese strategy: + # If the expected value for never playing round based on the fold percentage of the opponent in the last 250 rounds + # of the game lands you in the positive, then cheese and guarantee the win. Margin of error is 20 as it is reevaluated at + # each step in the game + elif (game_state.round_num >= 750 + and passive_EV + game_state.bankroll > 20): + print("Started Cheesin") + if FoldAction in legal_actions: + return FoldAction() + return CheckAction() # Pre-flop if street == 0: @@ -129,12 +157,13 @@ def get_action(self, game_state, round_state, active): self.cheese = False max_preflop_bet = int((my_stack + my_pip) * .2 * hole_strength) + min_raise, max_raise = round_state.raise_bounds() if (hole_strength == 0 and continue_cost > 0 and FoldAction in legal_actions): if not bool(active): if RaiseAction in legal_actions: self.cheese = True - return RaiseAction(5) + return RaiseAction(min_raise) elif continue_cost <=5: self.cheese = True return CallAction() @@ -142,7 +171,7 @@ def get_action(self, game_state, round_state, active): elif (hole_strength * 0.7 > continue_cost / (continue_cost + pot) and RaiseAction in legal_actions and my_contribution < max_preflop_bet): # TODO: tweak 0.85 - min_raise, max_raise = round_state.raise_bounds() + if hole_pair: bet = min(int((min_raise + ((max_raise - min_raise) * .1) ** hole_strength)), max_preflop_bet) * 3 @@ -164,7 +193,7 @@ def get_action(self, game_state, round_state, active): if not bool(active): if RaiseAction in legal_actions: self.cheese = True - return RaiseAction(5) + return RaiseAction(min_raise) elif continue_cost <=5: self.cheese = True return CallAction()