當前位置: 首頁>>代碼示例>>Python>>正文


Python Game.play方法代碼示例

本文整理匯總了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")
開發者ID:dgdavis00,項目名稱:django-tictactoe,代碼行數:9,代碼來源:test_models.py

示例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)
開發者ID:dgdavis00,項目名稱:django-tictactoe,代碼行數:9,代碼來源:test_models.py

示例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")
開發者ID:dgdavis00,項目名稱:django-tictactoe,代碼行數:9,代碼來源:test_models.py

示例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 ")
開發者ID:M-V-Mounica,項目名稱:django-tictactoe,代碼行數:11,代碼來源:test_players.py

示例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)
開發者ID:dgdavis00,項目名稱:django-tictactoe,代碼行數:10,代碼來源:test_models.py

示例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)
開發者ID:claudiordgz,項目名稱:Tic-Tac-Toe,代碼行數:7,代碼來源:test_players.py


注:本文中的game.models.Game.play方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。