本文整理匯總了Python中game.models.Game.play方法的典型用法代碼示例。如果您正苦於以下問題:Python Game.play方法的具體用法?Python Game.play怎麽用?Python Game.play使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類game.models.Game
的用法示例。
在下文中一共展示了Game.play方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_play_first
# 需要導入模塊: from game.models import Game [as 別名]
# 或者: from game.models.Game import play [as 別名]
def test_play_first(self):
"X always goes first"
game = Game()
game.play(0)
self.assertEqual(game.board, "X ")
self.assertEqual(game.next_player, "O")
示例2: test_play_error_square_taken
# 需要導入模塊: from game.models import Game [as 別名]
# 或者: from game.models.Game import play [as 別名]
def test_play_error_square_taken(self):
"You can't play a square that is taken."
game = Game(board="XOX ")
with self.assertRaises(ValueError):
game.play(1)
game.play(2)
示例3: test_play_second
# 需要導入模塊: from game.models import Game [as 別名]
# 或者: from game.models.Game import play [as 別名]
def test_play_second(self):
"The second play is O"
game = Game(board="X ")
game.play(1)
self.assertEqual(game.board, "XO ")
self.assertEqual(game.next_player, "X")
示例4: test_random
# 需要導入模塊: from game.models import Game [as 別名]
# 或者: from game.models.Game import play [as 別名]
def test_random(self):
"Basic testing."
random.seed(0) # For testing
game = Game()
p1 = RandomPlayer()
game.play(p1.play(game))
self.assertEqual(game.board, " X " if six.PY3 else " X ")
示例5: test_play_error_index
# 需要導入模塊: from game.models import Game [as 別名]
# 或者: from game.models.Game import play [as 別名]
def test_play_error_index(self):
"You can't pass in an invalid index."
game = Game()
with self.assertRaises(IndexError):
game.play(-1)
game.play(9)
game.play(10)
示例6: test_priorities_vertical
# 需要導入模塊: from game.models import Game [as 別名]
# 或者: from game.models.Game import play [as 別名]
def test_priorities_vertical(self):
p1 = AIPlayer()
game = Game(board="O XO X ",player_x=p1, player_o='human')
game.play(p1.play(game))
self.assertEqual("O XO X X", game.board)