本文整理汇总了Python中rules.Rules.get_current_player方法的典型用法代码示例。如果您正苦于以下问题:Python Rules.get_current_player方法的具体用法?Python Rules.get_current_player怎么用?Python Rules.get_current_player使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rules.Rules
的用法示例。
在下文中一共展示了Rules.get_current_player方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestRules
# 需要导入模块: from rules import Rules [as 别名]
# 或者: from rules.Rules import get_current_player [as 别名]
class TestRules(unittest.TestCase):
def setUp(self):
self.board = Board()
self.rule = Rules(self.board)
def test_next_play(self):
self.assertTrue(True)
def test_end_game_vertical(self):
for position in xrange(1, 10, 3):
self.rule.get_current_player()
self.board.add_mark('X', position) # 1, 4, 7
is_end, result = self.rule.end_game(position)
self.assertEqual(self.rule.remaining_moves, 6)
self.assertEqual(is_end, True)
self.assertEqual(result, 'win')
self.board.reset_board()
for position in xrange(2, 11, 3):
self.rule.get_current_player()
self.board.add_mark('X', position) # 2, 5, 8
is_end, result = self.rule.end_game(position)
self.assertEqual(self.rule.remaining_moves, 3)
self.assertEqual(is_end, True)
self.assertEqual(result, 'win')
def test_end_game_horizontal(self):
for position in xrange(1, 4):
self.rule.get_current_player()
self.board.add_mark('O', position)
is_end, result = self.rule.end_game(position)
self.assertEqual(self.rule.remaining_moves, 6)
self.assertEqual(is_end, True)
self.assertEqual(result, 'win')
def test_end_game_forward_diaganol(self):
for position in xrange(3, 9, 2):
self.rule.get_current_player()
self.board.add_mark('X', position)
is_end, result = self.rule.end_game(position)
self.assertEqual(self.rule.remaining_moves, 6)
self.assertEqual(is_end, True)
self.assertEqual(result, 'win')
def test_end_game_reverse_diaganol(self):
for position in xrange(1, 10, 4):
self.rule.get_current_player()
self.board.add_mark('O', position)
is_end, result = self.rule.end_game(position)
self.assertEqual(self.rule.remaining_moves, 6)
self.assertEqual(is_end, True)
self.assertEqual(result, 'win')
def test_end_game_draw(self):
for position in xrange(1, 10):
self.rule.get_current_player()
is_end, result = self.rule.end_game(position)
self.assertEqual(self.rule.remaining_moves, 0)
self.assertEqual(is_end, True)
self.assertEqual(result, 'draw')