From 9608449ca1a7bf6fa64944391e62b1cb44280e8c Mon Sep 17 00:00:00 2001 From: Tuschristine Date: Fri, 12 Jan 2024 14:17:52 -0500 Subject: [PATCH 1/3] updating code from main --- python_skeleton/player.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/python_skeleton/player.py b/python_skeleton/player.py index d30d8fb..9ee1521 100644 --- a/python_skeleton/player.py +++ b/python_skeleton/player.py @@ -30,6 +30,7 @@ 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 def handle_new_round(self, game_state, round_state, active): ''' @@ -70,6 +71,10 @@ 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 (street == 0 + and previous_state.) + self.opp_fold_pct += pass def get_action(self, game_state, round_state, active): @@ -101,10 +106,22 @@ 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 + passive_EV = (1.5 * (self.opp_fold_pct) - 3 * (1-self.opp_fold_pct)) * (1000 - game_state.round_num) + 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.my_bankroll > 20): + if FoldAction in legal_actions: + return FoldAction() + return CheckAction() # Pre-flop if street == 0: From e87b3db2ca29e26d7d1d994c8ebc64794e973130 Mon Sep 17 00:00:00 2001 From: Tuschristine Date: Fri, 12 Jan 2024 14:46:46 -0500 Subject: [PATCH 2/3] new cheese strat --- python_skeleton/player.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/python_skeleton/player.py b/python_skeleton/player.py index bd0c315..2fddf56 100644 --- a/python_skeleton/player.py +++ b/python_skeleton/player.py @@ -71,10 +71,12 @@ 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 if (street == 0 - and previous_state.) - self.opp_fold_pct += + and ((previous_state.pips[1 - active] == 2 and not bool(active)) + or (previous_state.pips[1 - active] == 1 and bool(active)))): + self.opp_fold_cnt += 1 pass def get_action(self, game_state, round_state, active): @@ -107,7 +109,11 @@ def get_action(self, game_state, round_state, active): pot = my_contribution + opp_contribution # Expected value from not playing - passive_EV = (1.5 * (self.opp_fold_pct) - 3 * (1-self.opp_fold_pct)) * (1000 - game_state.round_num) + current_opp_fold_pct = self.opp_fold_cnt / game_state.round_num + 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: @@ -118,7 +124,7 @@ def get_action(self, game_state, round_state, active): # 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.my_bankroll > 20): + and passive_EV + game_state.bankroll > 20): if FoldAction in legal_actions: return FoldAction() return CheckAction() @@ -148,7 +154,7 @@ def get_action(self, game_state, round_state, active): if (hole_strength == 0 and continue_cost > 5 and FoldAction in legal_actions): if not bool(active): if RaiseAction in legal_actions: - return RaiseAction(5) + return RaiseAction(3) elif continue_cost <=5: return CallAction() print("folded A") @@ -177,7 +183,7 @@ def get_action(self, game_state, round_state, active): if continue_cost + my_contribution > max_preflop_bet and not hole_pair and hole_strength < .67: if not bool(active): if RaiseAction in legal_actions: - return RaiseAction(5) + return RaiseAction(3) elif continue_cost <=5: return CallAction() return FoldAction() From f74c9d03fed756b592b943e65ad8fc36ed70dc96 Mon Sep 17 00:00:00 2001 From: Tuschristine Date: Fri, 12 Jan 2024 15:03:42 -0500 Subject: [PATCH 3/3] fixed fold count logic (hopefully) --- python_skeleton/player.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/python_skeleton/player.py b/python_skeleton/player.py index 2fddf56..cd81fc3 100644 --- a/python_skeleton/player.py +++ b/python_skeleton/player.py @@ -30,7 +30,7 @@ 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 + self.opp_fold_cnt = (0, 1) # Opponent opportunites to fold def handle_new_round(self, game_state, round_state, active): ''' @@ -73,10 +73,14 @@ def handle_round_over(self, game_state, terminal_state, active): 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)))): - self.opp_fold_cnt += 1 + 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): @@ -109,7 +113,7 @@ def get_action(self, game_state, round_state, active): pot = my_contribution + opp_contribution # Expected value from not playing - current_opp_fold_pct = self.opp_fold_cnt / game_state.round_num + 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) @@ -125,6 +129,7 @@ def get_action(self, game_state, round_state, active): # 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() @@ -150,11 +155,12 @@ def get_action(self, game_state, round_state, active): 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 > 5 and FoldAction in legal_actions): if not bool(active): if RaiseAction in legal_actions: - return RaiseAction(3) + return RaiseAction(min_raise) elif continue_cost <=5: return CallAction() print("folded A") @@ -162,7 +168,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 @@ -183,7 +189,7 @@ def get_action(self, game_state, round_state, active): if continue_cost + my_contribution > max_preflop_bet and not hole_pair and hole_strength < .67: if not bool(active): if RaiseAction in legal_actions: - return RaiseAction(3) + return RaiseAction(min_raise) elif continue_cost <=5: return CallAction() return FoldAction()