예제 #1
0
    def test_ShouldCalculateProfitsForBiggestSampleHandsOnTheSmallBlind(self):
        hands = parse_files([test_dir + '/data/sorted_sb.hand'])

        hand = hands[0]
        self.assertAlmostEqual(9.67, hand.profit_for_player('pobedito'), 2)
        self.assertAlmostEqual(-10.52, hand.profit_for_player('HubertusB'), 2)
        self.assertAlmostEqual(-0.10, hand.profit_for_player('8_PILOT_8'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('MaikStasiv'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('VDK_Ukr'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('GerDaTobe'), 2)

        hand = hands[1]
        self.assertAlmostEqual(0, hand.profit_for_player('Driver1966ss'), 2)
        self.assertAlmostEqual(4.82, hand.profit_for_player('HubertusB'), 2)
        self.assertAlmostEqual(-0.10, hand.profit_for_player('cupko0'), 2)
        self.assertAlmostEqual(-4.98, hand.profit_for_player('davejb68'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('huang hans01'), 2)
        self.assertAlmostEqual(-0.20, hand.profit_for_player('pool_king111'),
                               2)

        hand = hands[2]
        self.assertAlmostEqual(3.28, hand.profit_for_player('vlad oleynik'), 2)
        self.assertAlmostEqual(-3.50, hand.profit_for_player('HubertusB'), 2)
        self.assertAlmostEqual(-0.10, hand.profit_for_player('starkmage'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('KnME'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('-Z3RO_DAY-'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('Gostina'), 2)
예제 #2
0
    def test_ShouldParseCorrectlyOpenRaiseTimeoutAndAllFoldsPre(self):
        hands = parse_files(
            [test_dir + '/data/openraise_timeout_uncalled.hand'])
        self.assertEqual(1, len(hands))
        hand = hands[0]
        self.assertEqual(0.00, hand.rake)

        preflopFolds = [Action(ActionType.Fold, 0)]
        self.assertPlayer(hand, 'PLAYER_UTG', 'UTG', preflopFolds, [], [], [])
        self.assertPlayer(hand, 'PLAYER_CO', 'CO', preflopFolds, [], [], [])
        self.assertPlayer(hand, 'PLAYER_BTN', 'BTN', preflopFolds, [], [], [])
        self.assertPlayer(hand, 'PLAYER_MP', 'MP', preflopFolds, [], [], [])

        sbActions = [
            Action(ActionType.Post, 0.05),
            Action(ActionType.Raise, 0.20),
            Action(ActionType.Fold, 0)
        ]
        self.assertPlayer(hand, 'PLAYER_SB', 'SB', sbActions, [], [], [])

        bbActions = [
            Action(ActionType.Post, 0.10),
            Action(ActionType.Raise, 0.65),
            Action(ActionType.Uncalled, 0.45)
        ]
        self.assertPlayer(hand, 'PLAYER_BB', 'BB', bbActions, [], [], [])
예제 #3
0
    def test_ShouldCalculateProfitForParsedHandFoldPre(self):
        hands = parse_files([test_dir + '/data/fold_pre.hand'])
        self.assertEqual(1, len(hands))
        hand = hands[0]

        self.assertAlmostEqual(0, hand.profit_for_player('PLAYER_BTN'), 2)
        self.assertAlmostEqual(-0.05, hand.profit_for_player('PLAYER_SB'), 2)
        self.assertAlmostEqual(-0.10, hand.profit_for_player('PLAYER_BB'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('PLAYER_UTG'), 2)
        self.assertAlmostEqual(0.15, hand.profit_for_player('PLAYER_MP'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('PLAYER_CO'), 2)
예제 #4
0
    def test_ShouldCalculateProfitForParsedHandBlinidVsBlindTimeout(self):
        hands = parse_files(
            [test_dir + '/data/openraise_timeout_uncalled.hand'])
        self.assertEqual(1, len(hands))
        hand = hands[0]

        self.assertAlmostEqual(0, hand.profit_for_player('PLAYER_BTN'), 2)
        self.assertAlmostEqual(-0.20, hand.profit_for_player('PLAYER_SB'), 2)
        self.assertAlmostEqual(0.20, hand.profit_for_player('PLAYER_BB'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('PLAYER_UTG'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('PLAYER_MP'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('PLAYER_CO'), 2)
예제 #5
0
    def test_ShouldCalculateProfitForParsedHandOpenRaiseBetBetBetUncalled(
            self):
        hands = parse_files(
            [test_dir + '/data/openraise_bet_bet_bet_uncalled.hand'])
        self.assertEqual(1, len(hands))
        hand = hands[0]

        self.assertAlmostEqual(0, hand.profit_for_player('PLAYER_BTN'), 2)
        self.assertAlmostEqual(-1.60, hand.profit_for_player('PLAYER_SB'), 2)
        self.assertAlmostEqual(-0.10, hand.profit_for_player('PLAYER_BB'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('PLAYER_UTG'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('PLAYER_MP'), 2)
        self.assertAlmostEqual(1.55, hand.profit_for_player('PLAYER_CO'), 2)
예제 #6
0
    def test_ShouldCalculateProfitsForBiggestSampleHandsOnTheButton(self):
        hands = parse_files([test_dir + '/data/sorted_btn.hand'])

        hand = hands[0]
        self.assertAlmostEqual(10.71, hand.profit_for_player('HubertusB'), 2)
        self.assertAlmostEqual(-0.05, hand.profit_for_player('longbreath'), 2)
        self.assertAlmostEqual(-0.10, hand.profit_for_player('dima kk club'),
                               2)
        self.assertAlmostEqual(-0.35, hand.profit_for_player('Forstning'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('Skeleton1007'), 2)
        self.assertAlmostEqual(-11.24, hand.profit_for_player('Retro66'), 2)

        hand = hands[1]
        self.assertAlmostEqual(-9.75, hand.profit_for_player('HubertusB'), 2)
        self.assertAlmostEqual(-0.05, hand.profit_for_player('cotyara1986'), 2)
        self.assertAlmostEqual(-0.10, hand.profit_for_player('Snegul'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('KnME'), 2)
        self.assertAlmostEqual(-0.20, hand.profit_for_player('kasztanek136'),
                               2)
        self.assertAlmostEqual(9.21, hand.profit_for_player('littlekhans'), 2)

        hand = hands[2]
        self.assertAlmostEqual(6.88, hand.profit_for_player('HubertusB'), 2)
        self.assertAlmostEqual(-0.05, hand.profit_for_player('MrDaxooo'), 2)
        self.assertAlmostEqual(-0.10, hand.profit_for_player('Adrian197879'),
                               2)
        self.assertAlmostEqual(-0.30, hand.profit_for_player('takezo0229'), 2)
        self.assertAlmostEqual(-7.09, hand.profit_for_player('Takich7'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('ckostt'), 2)

        hand = hands[3]
        self.assertAlmostEqual(6.19, hand.profit_for_player('HubertusB'), 2)
        self.assertAlmostEqual(-0.05, hand.profit_for_player('kosta455'), 2)
        self.assertAlmostEqual(-0.10, hand.profit_for_player('aruranka'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('pody606'), 2)
        self.assertAlmostEqual(-6.64, hand.profit_for_player('afrika14'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('bratykow'), 2)

        hand = hands[4]
        self.assertAlmostEqual(5.7, hand.profit_for_player('HubertusB'), 2)
        self.assertAlmostEqual(-0.05, hand.profit_for_player('MOSUTANA'), 2)
        self.assertAlmostEqual(-0.10, hand.profit_for_player('0Darkman0'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('_-BATRIM-_'), 2)
        self.assertAlmostEqual(-6.11, hand.profit_for_player('piirakka87'), 2)
        self.assertAlmostEqual(0, hand.profit_for_player('straicar'), 2)
예제 #7
0
    def test_ShouldParseCorrectlyOpenRaiseBetBetBetUncalledHand(self):
        hands = parse_files(
            [test_dir + '/data/openraise_bet_bet_bet_uncalled.hand'])
        self.assertEqual(1, len(hands))
        hand = hands[0]
        self.assertEqual('1', hand.id)
        self.assertEqual((0.05, 0.10), hand.stakes)
        self.assertEqual(6, len(hand.players))
        self.assertEqual(0.15, hand.rake)

        preflop = [Action(ActionType.Fold, 0)]
        self.assertPlayer(hand, 'PLAYER_BTN', 'BTN', preflop, [], [], [])

        preflop = [
            Action(ActionType.Post, 0.05),
            Action(ActionType.Call, 0.25)
        ]
        flop = [Action(ActionType.Check, 0), Action(ActionType.Call, 0.40)]
        turn = [Action(ActionType.Check, 0), Action(ActionType.Call, 0.90)]
        river = [Action(ActionType.Check, 0), Action(ActionType.Fold, 0)]
        self.assertPlayer(hand, 'PLAYER_SB', 'SB', preflop, flop, turn, river)

        preflop = [Action(ActionType.Post, 0.10), Action(ActionType.Fold, 0)]
        self.assertPlayer(hand, 'PLAYER_BB', 'BB', preflop, [], [], [])

        preflop = [Action(ActionType.Fold, 0)]
        self.assertPlayer(hand, 'PLAYER_UTG', 'UTG', preflop, [], [], [])
        self.assertPlayer(hand, 'PLAYER_MP', 'MP', preflop, [], [], [])

        preflop = [Action(ActionType.Raise, 0.30)]
        flop = [Action(ActionType.Bet, 0.40)]
        turn = [Action(ActionType.Bet, 0.90)]
        river = [
            Action(ActionType.Bet, 2.00),
            Action(ActionType.Uncalled, 2.00)
        ]
        self.assertEqual('AA', hand.players['PLAYER_CO'].holding)
        self.assertEqual(3.15, hand.players['PLAYER_CO'].collected)
        self.assertPlayer(hand, 'PLAYER_CO', 'CO', preflop, flop, turn, river)