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


Python Game.drop_round方法代码示例

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


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

示例1: test_get_pieces

# 需要导入模块: from lib.game import Game [as 别名]
# 或者: from lib.game.Game import drop_round [as 别名]
 def test_get_pieces(self):
     g = Game(rows=1)
     g.drop_cross(0)
     g.drop_round(1)
     self.assertTrue((0,0) in g._get_pieces('X'))
     self.assertFalse((1,0) in g._get_pieces('X'))
     self.assertTrue((1,0) in g._get_pieces('O'))
     self.assertFalse((0,0) in g._get_pieces('O'))
开发者ID:cabello,项目名称:connect-four,代码行数:10,代码来源:game_test.py

示例2: test_horizontal_win_by_round

# 需要导入模块: from lib.game import Game [as 别名]
# 或者: from lib.game.Game import drop_round [as 别名]
 def test_horizontal_win_by_round(self):
     # Horizontal win using round
     g = Game()
     [g.drop_round(i) for i in range(4)]
     self.assertTrue(g._horizontal_win('O'))
     self.assertFalse(g._horizontal_win('X'))
开发者ID:cabello,项目名称:connect-four,代码行数:8,代码来源:game_test.py

示例3: test_vertical_win_by_round

# 需要导入模块: from lib.game import Game [as 别名]
# 或者: from lib.game.Game import drop_round [as 别名]
 def test_vertical_win_by_round(self):
     # Vertical win using round
     g = Game()
     [g.drop_round(0) for i in range(4)]
     self.assertTrue(g._vertical_win('O'))
     self.assertFalse(g._vertical_win('X'))
开发者ID:cabello,项目名称:connect-four,代码行数:8,代码来源:game_test.py

示例4: test_drop_round_on_full_column_raises

# 需要导入模块: from lib.game import Game [as 别名]
# 或者: from lib.game.Game import drop_round [as 别名]
 def test_drop_round_on_full_column_raises(self):
     g = Game(rows=2)
     self.assertEquals(g.drop_round(0), (0,1))
     self.assertEquals(g.drop_round(0), (0,0))
     self.assertRaises(ColumnFullException, g.drop_round, 0)
开发者ID:cabello,项目名称:connect-four,代码行数:7,代码来源:game_test.py

示例5: test_drop_round

# 需要导入模块: from lib.game import Game [as 别名]
# 或者: from lib.game.Game import drop_round [as 别名]
 def test_drop_round(self):
     g = Game()
     self.assertEquals(g.drop_round(0), (0,5))
     self.assertTrue((0,5) in g._round_pieces)
开发者ID:cabello,项目名称:connect-four,代码行数:6,代码来源:game_test.py

示例6: test_diagonal_win_by_cross

# 需要导入模块: from lib.game import Game [as 别名]
# 或者: from lib.game.Game import drop_round [as 别名]
    def test_diagonal_win_by_cross(self):
        """
        Diagonal win using this structure
              X
            X O
          X O O
        X O O O
        """
        g = Game()
        g.drop_cross(0)
        g.drop_round(1)
        g.drop_cross(1)
        g.drop_round(2)
        g.drop_round(2)
        g.drop_cross(2)
        g.drop_round(3)
        g.drop_round(3)
        g.drop_round(3)
        g.drop_cross(3)
        self.assertTrue(g._diagonal_win('X'))

        """
        Diagonal win using this structure
        X
        O X
        O O X
        O O O X
        """
        g = Game()
        g.drop_cross(3)
        g.drop_round(2)
        g.drop_cross(2)
        g.drop_round(1)
        g.drop_round(1)
        g.drop_cross(1)
        g.drop_round(0)
        g.drop_round(0)
        g.drop_round(0)
        g.drop_cross(0)
        self.assertTrue(g._diagonal_win('X'))
        self.assertFalse(g._diagonal_win('O'))

        # No victory, insufficient total pieces
        g = Game()
        [g.drop_cross(i) for i in range(3)]
        self.assertFalse(g._diagonal_win('X'))
开发者ID:cabello,项目名称:connect-four,代码行数:48,代码来源:game_test.py


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