Пример #1
0
    def test_compare(self):
        """

        """
        h1 = [
            roomai.games.texasholdem.PokerCard(7, 0),
            roomai.games.texasholdem.PokerCard(7, 1)
        ]
        h2 = [
            roomai.games.texasholdem.PokerCard(2, 0),
            roomai.games.texasholdem.PokerCard(2, 1)
        ]
        h3 = [
            roomai.games.texasholdem.PokerCard(2, 2),
            roomai.games.texasholdem.PokerCard(2, 3)
        ]
        k = [
            roomai.games.texasholdem.PokerCard(3, 1),
            roomai.games.texasholdem.PokerCard(4, 2),
            roomai.games.texasholdem.PokerCard(5, 3),
            roomai.games.texasholdem.PokerCard(6, 0),
            roomai.games.texasholdem.PokerCard(7, 2)
        ]

        p1 = TexasHoldemEnv.__cards2pattern_cards__(h1, k)
        p2 = TexasHoldemEnv.__cards2pattern_cards__(h2, k)
        p3 = TexasHoldemEnv.__cards2pattern_cards__(h3, k)
Пример #2
0
    def test_cards(self):
        """

        """
        handcards1 = [
            roomai.games.texasholdem.PokerCard(0, 0),
            roomai.games.texasholdem.PokerCard(0, 1)
        ]
        handcards2 = [
            roomai.games.texasholdem.PokerCard(3, 1),
            roomai.games.texasholdem.PokerCard(3, 2)
        ]
        keepcards = [
            roomai.games.texasholdem.PokerCard(0, 2),
            roomai.games.texasholdem.PokerCard(0, 3),
            roomai.games.texasholdem.PokerCard(2, 0),
            roomai.games.texasholdem.PokerCard(2, 1),
            roomai.games.texasholdem.PokerCard(3, 3)
        ]
        pattern = TexasHoldemEnv.__cards2pattern_cards__(
            handcards1, keepcards)[0]
        cards = TexasHoldemEnv.__cards2pattern_cards__(handcards1,
                                                       keepcards)[1]
        self.assertEqual(pattern[0], '4_1')
        self.assertEqual(pattern[1], False)
        self.assertEqual(pattern[2], True)
        self.assertEqual(pattern[3], False)
        self.assertEqual(pattern[4][0], 4)
        self.assertEqual(pattern[4][1], 1)
        self.assertEqual(cards[0].point_rank, 0)
        self.assertEqual(cards[1].point_rank, 0)
        self.assertEqual(cards[2].point_rank, 0)
        self.assertEqual(cards[3].point_rank, 0)
        self.assertEqual(cards[4].point_rank, 3)

        self.assertEqual(cards[0].suit_rank, 0)
        self.assertEqual(cards[1].suit_rank, 1)
        self.assertEqual(cards[2].suit_rank, 2)
        self.assertEqual(cards[3].suit_rank, 3)
        self.assertEqual(cards[4].suit_rank, 3)

        pattern1 = TexasHoldemEnv.__cards2pattern_cards__(
            handcards1, keepcards)
        pattern2 = TexasHoldemEnv.__cards2pattern_cards__(
            handcards2, keepcards)

        diff = TexasHoldemEnv.__compare_handcards__(handcards1, handcards2,
                                                    keepcards)
        self.assertTrue(diff > 0)
Пример #3
0
    def test_pattern(self):
        """

        """

        handcards1 = [
            roomai.games.texasholdem.PokerCard(0, 0),
            roomai.games.texasholdem.PokerCard(1, 1)
        ]
        keepcards = [
            roomai.games.texasholdem.PokerCard(2, 2),
            roomai.games.texasholdem.PokerCard(3, 3),
            roomai.games.texasholdem.PokerCard(4, 0),
            roomai.games.texasholdem.PokerCard(5, 1),
            roomai.games.texasholdem.PokerCard(6, 2)
        ]
        pattern = TexasHoldemEnv.__cards2pattern_cards__(handcards1, keepcards)
Пример #4
0
    def test_cards2(self):
        """

        """

        h1 = [
            roomai.games.texasholdem.PokerCard(7, 0),
            roomai.games.texasholdem.PokerCard(7, 1)
        ]
        keep = [
            roomai.games.texasholdem.PokerCard(3, 1),
            roomai.games.texasholdem.PokerCard(4, 2),
            roomai.games.texasholdem.PokerCard(5, 3),
            roomai.games.texasholdem.PokerCard(6, 0),
            roomai.games.texasholdem.PokerCard(7, 2)
        ]
        pattern = TexasHoldemEnv.__cards2pattern_cards__(h1, keep)[0]
        self.assertEqual(pattern[0], "3_1_1")