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


Python Analyzer._straight方法代码示例

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


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

示例1: TestAnalyzer

# 需要导入模块: from analyzer import Analyzer [as 别名]
# 或者: from analyzer.Analyzer import _straight [as 别名]

#.........这里部分代码省略.........
        # trips
        self.p2.hole[0].value = 14
        self.p2.hole[1].value = 12

        # two pair
        self.p3.hole[0].value = 12
        self.p3.hole[1].value = 12

        # pair
        self.p4.hole[0].value = 12
        self.p4.hole[1].value = 11

        self.p4.hole[2].value = 14
        self.p4.hole[3].value = 14
        self.p4.hole[4].value = 13
        self.p4.hole[5].value = 3
        self.p4.hole[6].value = 2

        players = self.analyzer._order(players)

        self.analyzer._matching(players)

        # Do we have 4 A's with a K kicker?
        self.assertEqual(self.p0.hand, [7, 14, 13])
        # Do we have a boat A's full of K's?
        self.assertEqual(self.p1.hand, [6, 14, 13])
        # Do we have trip A's with K & Q kickers?
        self.assertEqual(self.p2.hand, [3, 14, 13, 12])
        # Do we have 2 pair A's & Q's with a K kicker?
        self.assertEqual(self.p3.hand, [2, 14, 12, 13])
        # Do we have a pair of A's with K, Q, J kickers?
        self.assertEqual(self.p4.hand, [1, 14, 13, 12, 11])

    def test_straight(self ):
        """can we find the highest straight in a hand"""
        players = self.analyzer._setup()
        #p0 has a 6 high straight
        self.p0.hole[0].value = 8
        self.p0.hole[1].value = 6
        self.p0.hole[2].value = 5
        self.p0.hole[3].value = 4
        self.p0.hole[4].value = 3
        self.p0.hole[5].value = 13
        self.p0.hole[6].value = 2
        #poor p1 hit the wheel
        self.p1.hole[0].value = 14
        self.p1.hole[1].value = 11

        self.analyzer._order(players)

        self.analyzer._straight(self.p0)
        self.analyzer._straight(self.p1)
        expected_0 = [4, 6]
        expected_1 = [4, 5]
        self.assertEqual(self.p0.hand, expected_0)
        self.assertEqual(self.p1.hand, expected_1)

    def test_flush(self):
        """Can we find a flush in the players' hands"""
        players = self.analyzer._setup()
        # a flush
        self.p0.hole[0].suit = "d"
        self.p0.hole[0].value = 2
        self.p0.hole[1].suit = "d"
        self.p0.hole[1].value = 2
        self.p0.hole[2].suit = "d"
开发者ID:mrbubba,项目名称:Poker,代码行数:70,代码来源:test_analyzer.py


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