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


Python Board.fill_position方法代码示例

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


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

示例1: test_if_game_has_finnished_by_user_winning

# 需要导入模块: import Board [as 别名]
# 或者: from Board import fill_position [as 别名]
    def test_if_game_has_finnished_by_user_winning(self):
        b = Board(3)
        p = {"andy": "X", "nick": "O"}
        g = Game(b, p)

        for i in range(3):
            for j in range(3):
                b.fill_position(i, j, "X")

        self.assertTrue(g.is_game_finnished(), "game is not finnished")
开发者ID:andrebrito,项目名称:py-studies,代码行数:12,代码来源:GameTest.py

示例2: test_if_game_has_finnished_by_board_completion

# 需要导入模块: import Board [as 别名]
# 或者: from Board import fill_position [as 别名]
    def test_if_game_has_finnished_by_board_completion(self):
        b = Board(3)
        p = {"andy": "X", "nick": "O"}
        g = Game(b, p)

        for i in range(3):
            for j in range(3):
                b.fill_position(i, j, choice(ascii_uppercase))

        self.assertTrue(g.is_game_finnished(), "game is not finnished")
开发者ID:andrebrito,项目名称:py-studies,代码行数:12,代码来源:GameTest.py

示例3: test_if_can_mark_in_out_of_bound_position

# 需要导入模块: import Board [as 别名]
# 或者: from Board import fill_position [as 别名]
    def test_if_can_mark_in_out_of_bound_position(self):
        b = Board(3)
        p = {"andy": "X", "nick": "O"}
        g = Game(b, p)

        for i in range(3):
            for j in range(3):
                b.fill_position(i, j, "X")

        self.assertFalse(b.can_mark(3, 3), "can mark in 3, 3")
        self.assertFalse(b.can_mark(4, 4), "can mark in 4, 4")
        self.assertFalse(b.can_mark(-1, -1), "can mark in -1, -1")
开发者ID:andrebrito,项目名称:py-studies,代码行数:14,代码来源:GameTest.py

示例4: test_winners

# 需要导入模块: import Board [as 别名]
# 或者: from Board import fill_position [as 别名]
    def test_winners(self):
        b = Board(3)
        p = {"andy": "X", "nick": "O"}
        g = Game(b, p)

        for i in range(0, 3):
            b.fill_position(i, 0, "X")
        self.assertEquals(g.winner_name(), "andy", "andy is not the winner")
        b.clear()

        for i in range(0, 3):
            b.fill_position(i, 0, "O")
        self.assertEquals(g.winner_name(), "nick", "nick is not the winner")
        b.clear()
        
        for i in range(0, 3):
            b.fill_position(i, 2, "X")
        self.assertEquals(g.winner_name(), "andy", "andy is not the winner")
        b.clear()

        for i in range(0, 3):
            b.fill_position(0, i, "X")
        self.assertEquals(g.winner_name(), "andy", "andy is not the winner")
        b.clear()

        for i in range(0, 3):
            b.fill_position(2, i, "X")
        self.assertEquals(g.winner_name(), "andy", "andy is not the winner")
        b.clear()

        for i in range(0, 3):
            b.fill_position(i, i, "X")
        self.assertEquals(g.winner_name(), "andy", "andy is not the winner")
        b.clear()

        for i in range(2, -1, -1):
            b.fill_position(b.size() - i -1, i, "X")
        self.assertEquals(g.winner_name(), "andy", "andy is not the winner")
        b.clear()

        self.assertFalse(g.has_any_winner(), "has winner")
        b.clear()
开发者ID:andrebrito,项目名称:py-studies,代码行数:44,代码来源:GameTest.py


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