def betRequest(self, game_state): game = GameState(game_state) logger = Logger(game) player = game.our_player hole_cards = player.hole_cards community_cards = game.community_cards bet = player.bet stack = player.stack current_buy_in = game.current_buy_in minimum_raise = game.minimum_raise if len(community_cards) == 0: try: score = Preflop(game_state).score() if score > 14: logger.all_in("Chen > 14") return 4000 if score > 10: logger.check("Chen said it's fine (raise)") return current_buy_in - bet + minimum_raise if score < 6: logger.fold("Chen score is low") return 0 logger.check("Chen says we should check") return current_buy_in - bet except: print('WTF?') pass if hole_cards[0].rank == hole_cards[1].rank: if hole_cards[0].rank_value > 7: logger.all_in("high cards") return 1000 if hole_cards[0].rank_value > 9 or hole_cards[1].rank_value > 9: if current_buy_in > 400 and bet < 200: logger.fold("high card, high stakes, low money") return 0 logger.check("at least one high card") return current_buy_in - bet if current_buy_in > 350 and bet < 80: logger.fold("high stakes, low money") return 0 logger.check("no reason to stop now") return current_buy_in - bet
def test_high_value_5(self): self.assertEqual( 2.5, Preflop(self.mock_hole(["5D", "2D"])).high_card_value())
def test_high_value_6(self): self.assertEqual( 3, Preflop(self.mock_hole(["6D", "2D"])).high_card_value())
def test_high_value_10(self): self.assertEqual( 5, Preflop(self.mock_hole(["10D", "2D"])).high_card_value())
def test_name_high_A_rev(self): x = Preflop(self.mock_hole(["KD", "AD"])) self.assertEqual("High card A, low card K", x.name())
def test_name_high_A(self): x = Preflop(self.mock_hole(["AD", "KD"])) self.assertEqual(x.name(), "High card A, low card K")
def test_name_pair_K(self): x = Preflop(self.mock_hole(["KD", "KD"])) self.assertEqual(x.name(), "Pair of K")
def test_name_pair_A(self): x = Preflop(self.mock_hole(["AD", "AD"])) self.assertEqual(x.name(), "Pair of A")
def test_preflop_class(self): x = Preflop(self.mock_hole(["AD", "2H"])) self.assertIsInstance(x, Preflop)
def test_gap_gt_max(self): self.assertEqual(0, Preflop(self.mock_hole(["10D", "5H"])).score())
def test_score_pair_5(self): self.assertEqual(5, Preflop(self.mock_hole(["5D", "5H"])).score())
def test_score_5_4_same_suit(self): self.assertEqual(4, Preflop(self.mock_hole(["5D", "4D"])).score())
def test_score_5_4(self): self.assertEqual(2, Preflop(self.mock_hole(["5D", "4H"])).score())