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


Python GameState.history方法代码示例

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


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

示例1: test_interrogate_lets_you_cancel_and_do_nothing

# 需要导入模块: from GameState import GameState [as 别名]
# 或者: from GameState.GameState import history [as 别名]
    def test_interrogate_lets_you_cancel_and_do_nothing(self):
        try:
            old_raw_input = raw_input
            Interactive.raw_input = mock_raw_input('1', '3L', 'cancel')

            player = HumanPlayer('joe')
            tom = AIPlayer('tom')

            state = GameState()
            state.current_player = player
            state.players = [player, tom]
            state.history = []
            state.question_cards = [(1, 'L'), (3, 'L'), (7, 'L')]

            with captured_output() as (out, err):
                turn_ended = interrogate_command(state)

            self.assertEqual('Interrogate\n'
                             'Question cards: 1L 3L 7L', output(out))
            self.assertEqual(0, len(state.history))
            self.assertFalse(turn_ended)
        finally:
            Interactive.raw_input = old_raw_input
开发者ID:manurFR,项目名称:deduceia,代码行数:25,代码来源:TestInteractive.py

示例2: test_print_history

# 需要导入模块: from GameState import GameState [as 别名]
# 或者: from GameState.GameState import history [as 别名]
    def test_print_history(self):
        tom = HumanPlayer('Tom')
        juanpedro = HumanPlayer('Juan-Pedro')
        joe = HumanPlayer('Joe')
        history = [{'turn': 1, 'player': tom, 'opponent': juanpedro,
                    'range': Range((1, 'L'), (5, 'L')), 'result': 2, 'action': 'interrogate'},
                   {'turn': 2, 'player': joe, 'opponent': tom,
                    'range': Range((6, '$'), (6, '$'), choice='suit'), 'result': 0, 'action': 'interrogate'},
                   {'turn': 3, 'player': juanpedro, 'opponent': tom,
                    'range': Range((3, 'L'), (3, 'H')), 'result': 1, 'action': 'secret'},
                   {'turn': 4, 'player': tom, 'opponent': juanpedro,
                    'range': Range((4, '$'), (7, '$')), 'result': 0, 'action': 'secret'},
                   {'turn': 5, 'player': joe, 'opponent': tom,
                    'range': Range((9, 'H'), (3, 'H')), 'result': 4, 'action': 'secret'}]
        accusations = [{'player': tom, 'accused': juanpedro, 'cards': [(8, 'H'), (3, '$')], 'outcome': 'incorrect'},
                       {'player': juanpedro, 'accused': joe, 'cards': [(7, 'H'), (5, '$')], 'outcome': 'correct'}]

        state = GameState()
        state.history = history
        state.accusations = accusations
        state.current_player = juanpedro

        with captured_output() as (out, err):
            self.assertFalse(print_history(state))

        self.assertEqual('History\n'
                         'Turn  Player      Opponent    Range          Result  Note    \n'
                         '1     Tom         Juan-Pedro  1L->5L         2               \n'
                         '2     Joe         Tom         6$->6$ [suit]  0               \n'
                         '3     Juan-Pedro  Tom         3L->3H         1       (Secret)\n'
                         '4     Tom         Juan-Pedro  4$->7$         0       (Secret)\n'
                         '5     Joe         Tom         *************  ******  (Secret)\n'
                         '\n'
                         'Accusations\n'
                         '      Tom         Juan-Pedro  8H 3$          incorrect\n'
                         '      Juan-Pedro  Joe         7H 5$          correct',
                         output(out))
开发者ID:manurFR,项目名称:deduceia,代码行数:39,代码来源:TestInteractive.py


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