当前位置: 首页>>代码示例>>Python>>正文


Python Analyzer._award方法代码示例

本文整理汇总了Python中analyzer.Analyzer._award方法的典型用法代码示例。如果您正苦于以下问题:Python Analyzer._award方法的具体用法?Python Analyzer._award怎么用?Python Analyzer._award使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在analyzer.Analyzer的用法示例。


在下文中一共展示了Analyzer._award方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestAnalyzer

# 需要导入模块: from analyzer import Analyzer [as 别名]
# 或者: from analyzer.Analyzer import _award [as 别名]
class TestAnalyzer(unittest.TestCase):

    def setUp(self):
        self.p0 = Player('p0', 100)
        self.p1 = Player('p1', 100)
        self.p2 = Player('p2', 100)
        self.p3 = Player('p3', 100)
        self.p4 = Player('p4', 100)
        self.p5 = Player('p5', 100)

        self.s0 = Seat('s0')
        self.s1 = Seat('s1')
        self.s2 = Seat('s2')
        self.s3 = Seat('s3')
        self.s4 = Seat('s4')
        self.s5 = Seat('s5')

        players = [self.p0, self.p1, self.p2, self.p3, self.p4, self.p5]
        seats = [self.s0, self.s1, self.s2, self.s3, self.s4, self.s5]

        self.table = Table(seats, 5, 10, 0)
        self.dealer = Dealer(self.table)
        self.table.dealer = self.dealer

        player = 0
        for seat in seats:
            seat.player = players[player]
            seat.player.seat = seat
            seat.active = True
            seat.player.table = self.table
            player += 1

        self.table.init_hand()
        self.dealer.deal()
        self.dealer.deal()
        self.dealer.deal()
        self.analyzer = Analyzer(self.table)

    def test_award(self):
        """can we award a single winner the entire pot?"""
        players = [self.p2]
        self.table.pots[0].pot = 100
        self.p2.stack = 90
        self.analyzer._award(players)

        self.assertEqual(self.p2.stack, 190)

    def test_award_multiple(self):
        """Can we pay out evenly to multiple winners?"""
        players = [self.p2, self.p3]
        self.table.pots[0].pot = 100
        self.p2.stack = 50
        self.p3.stack = 50
        self.analyzer._award(players)

        self.assertEqual(self.p2.stack, 100)
        self.assertEqual(self.p3.stack, 100)

    def test_award_indivisible(self):
        """Can we properly pay pots that don't divide
        evenly?"""
        players = [self.p2, self.p3]
        self.table.first = 1
        self.table.pots[0].pot = 105
        self.p2.stack = 50
        self.p3.stack = 50
        self.analyzer._award(players)

        self.assertEqual(self.p2.stack, 105)
        self.assertEqual(self.p3.stack, 100)

    def test_compare(self):
        """can we determine the winning hand"""
        players = self.analyzer._setup()

        self.p0.hand = [0, 14, 12, 11, 10, 8]
        self.p1.hand = [1, 14, 12, 11, 8]
        self.p2.hand = [7, 8, 14]
        self.p3.hand = [7, 10, 2]
        self.p4.hand = [0]
        self.p5.hand = [0]

        result = self.analyzer._compare(players)
        expected = [self.p3]
        self.assertEqual(expected, result)

    def test_compare_multiple(self):
        """if there are multiple winners do we
        return all of them?"""
        players = self.analyzer._setup()

        self.p0.hand = [0, 14, 12, 11, 10, 8]
        self.p1.hand = [1, 14, 12, 11, 8]
        self.p2.hand = [7, 10, 2]
        self.p3.hand = [7, 10, 2]
        self.p4.hand = [0]
        self.p5.hand = [0]

        result = self.analyzer._compare(players)
        expected = [self.p2, self.p3]
#.........这里部分代码省略.........
开发者ID:mrbubba,项目名称:Poker,代码行数:103,代码来源:test_analyzer.py


注:本文中的analyzer.Analyzer._award方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。