Пример #1
0
    def test_showdown_hs(self):
        e = Engine(
            'CoinPoker',
            1,
            {
                1: {
                    'name': 'joe',
                    'balance': 1000,
                    'status': 1
                },
                2: {
                    'name': 'joe',
                    'balance': 1000,
                    'status': 1
                },
            },
            50,
            100,
            0,
        )
        e.available_actions()

        # p1
        e.do(['r', 100])
        e.available_actions()

        # p2
        e.do(['c'])
        e.available_actions()

        # p2
        e.do(['k'])
        e.available_actions()

        # p1
        e.do(['b', 200])
        e.available_actions()

        # p2 has:
        # preflop_1 = l
        # preflop_2 = c
        # flop_1 = k
        hs = ES.showdown_hs(e, e.s, percentile=50)
        assert hs is not None
        assert 0 < hs < 1
        hs2 = ES.showdown_hs(e, e.s, percentile=10)
        assert hs2 < hs
        hs3 = ES.showdown_hs(e, e.s, percentile=90)
        assert hs3 > hs

        res = ES.showdown_hs(e, e.s, 200)
        hits = res.hits.hits
        assert len(hits) == 200
        assert hits[0]['_score'] > 4
        assert hits[-1]['_score'] > 0
Пример #2
0
    def test_showdown_hs(self):
        e = Engine(
            'CoinPoker', 1,
            {
                1: {'name': 'joe', 'balance': 1000, 'status': 1},
                2: {'name': 'joe', 'balance': 1000, 'status': 1},
            },
            50, 100, 0,
        )
        e.available_actions()

        # p1
        e.do(['r', 100])
        e.available_actions()

        # p2
        e.do(['c'])
        e.available_actions()

        # p2
        e.do(['k'])
        e.available_actions()

        # p1
        e.do(['b', 200])
        e.available_actions()

        # p2 has:
        # preflop_1 = l
        # preflop_2 = c
        # flop_1 = k
        hs = ES.showdown_hs(e, e.s, percentile=50)
        assert hs is not None
        assert 0 < hs < 1
        hs2 = ES.showdown_hs(e, e.s, percentile=10)
        assert hs2 < hs
        hs3 = ES.showdown_hs(e, e.s, percentile=90)
        assert hs3 > hs

        res = ES.showdown_hs(e, e.s, 200)
        hits = res.hits.hits
        assert len(hits) == 200
        assert hits[0]['_score'] > 4
        assert hits[-1]['_score'] > 0
Пример #3
0
 def get_showdown_equities(self, e):
     """instead of using pokereval, use hs from se"""
     hss = {}
     for s, d in e.data.items():
         if 'in' in d['status']:
             hss[s] = ES.showdown_hs(e, s, percentile=self.PERCENTILE)
     # calculate for hero
     if self.hero in hss:
         d = e.data[self.hero]
         hss[self.hero] = PE.hand_strength(d['hand'], e.board, e.rivals)
     # normalize
     total = sum(hs for hs in hss.values())
     equities = {s: hs / total for s, hs in hss.items()}
     return equities
Пример #4
0
 def get_showdown_equities(self, e):
     """instead of using pokereval, use hs from se"""
     hss = {}
     for s, d in e.data.items():
         if 'in' in d['status']:
             hss[s] = ES.showdown_hs(e, s, percentile=self.PERCENTILE)
     # calculate for hero
     if self.hero in hss:
         d = e.data[self.hero]
         hss[self.hero] = PE.hand_strength(d['hand'], e.board, e.rivals)
     # normalize
     total = sum(hs for hs in hss.values())
     equities = {s: hs / total for s, hs in hss.items()}
     return equities