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


Python Player.place_marker方法代码示例

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


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

示例1: ComputerPlayerTest

# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import place_marker [as 别名]
class ComputerPlayerTest(TestCase):

    def setUp(self):
        self.board = Board()
        self.player = Player("X", self.board, "Allan")
        self.computer = ComputerPlayer("O",self.board )

    def test_place_marker(self):
        self.player.place_marker(4)
        self.computer.place_marker()
        assert self.board.last_cell != 4
开发者ID:cajun-code,项目名称:Tic-Tac-Toe,代码行数:13,代码来源:tests.py

示例2: GameLoadTest

# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import place_marker [as 别名]
class GameLoadTest(TestCase):
    GAME_COUNT = 1000
    def setUp(self):
        self.board = Board()
        self.player = Player("X", self.board, "Sys")
        self.computer = ComputerPlayer("O",self.board)
        self.winners = {}
        self.moves = {}
        
    def play_game(self):
        sys_moves = []
        while self.board.winner == None:
            choice_made = False
            while not choice_made:
                choice = random.randrange(0, 9, 1)
                if choice not in sys_moves and self.board.get_cell(choice) == None:
                    sys_moves.append(choice)
                    choice_made = True
                    self.player.place_marker(choice)
                    if self.board.winner == None:
                        self.computer.place_marker()
        
        winner = self.board.winner
        if winner in self.winners.keys():
            self.winners[winner] = self.winners[winner] + 1
        else:
            self.winners[winner] = 1
        if winner == "X":
            move = sys_moves.__str__()
            if move in self.moves.keys():
                self.moves[move] = self.moves[move] + 1
            else:
                self.moves[move] = 1
            
    def test_game(self):
        for count in range(self.GAME_COUNT):
            self.play_game()
            self.board.clear()
        print "\n{0}".format(self.winners)
        print "\n{0}".format(self.moves)
开发者ID:cajun-code,项目名称:Tic-Tac-Toe,代码行数:42,代码来源:tests.py

示例3: PersonTest

# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import place_marker [as 别名]
class PersonTest(TestCase):

    def setUp(self):
        self.player = Player()

    def test_marker(self):
        assert self.player.marker == None
        self.player.marker = "X"
        assert self.player.marker == "X"

    def test_board(self):
        assert self.player.board == None
        self.player.board = Board()
        assert self.player.board != None

    def test_name(self):
        assert self.player.name == None
        self.player.name = "Allan"
        assert self.player.name == "Allan"
    def test_place_marker(self):
        board = Board()
        self.player = Player("X",board, "Allan")
        self.player.place_marker(4)
        assert board.get_cell(4) == "X"
开发者ID:cajun-code,项目名称:Tic-Tac-Toe,代码行数:26,代码来源:tests.py


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