本文整理匯總了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')