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


Python Simulator.find_solution方法代码示例

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


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

示例1: level_2

# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import find_solution [as 别名]
class level_2(unittest.TestCase):

    def setUp(self):
        self.game = Game()
        self.game.addSquare(Square(Color.blue, Direction.top, 2, 1))
        self.game.board.setColor(0, 1, Color.blue)
        self.game.addSquare(Square(Color.red, Direction.right, 0, 0))
        self.game.board.setColor(0, 2, Color.red)
        self.game.addSquare(Square(Color.grey, Direction.left, 1, 3))
        self.game.board.setColor(1, 1, Color.grey)

        self.simulator = Simulator(self.game)

    def test_goal(self):
        self.game.moveSquare(Color.red)
        self.assertTrue(not self.game.isDone())
        self.game.moveSquare(Color.red)
        self.assertTrue(not self.game.isDone())
        self.game.moveSquare(Color.blue)
        self.assertTrue(not self.game.isDone())
        self.game.moveSquare(Color.blue)
        self.assertTrue(not self.game.isDone())
        self.game.moveSquare(Color.grey)
        self.assertTrue(not self.game.isDone())
        self.game.moveSquare(Color.grey)
        self.assertTrue(self.game.isDone())

    def test_simulation(self):
        print self.simulator.find_solution()
开发者ID:haudren,项目名称:squares,代码行数:31,代码来源:tests.py

示例2: level_0

# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import find_solution [as 别名]
class level_0(unittest.TestCase):

    def setUp(self):
        self.game = Game()
        self.game.addSquare(Square(Color.red, Direction.bottom, 0, 0))
        self.game.board.setColor(2, 0, Color.red)

        self.simulator = Simulator(self.game)

    def test_goal(self):
        self.game.moveSquare(Color.red)
        self.game.moveSquare(Color.red)
        self.assertTrue(self.game.isDone())

    def test_simulation(self):
        print self.simulator.find_solution()
开发者ID:haudren,项目名称:squares,代码行数:18,代码来源:tests.py

示例3: level_31

# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import find_solution [as 别名]
class level_31(unittest.TestCase):

    def setUp(self):
        self.game = Game()
        self.game.addSquare(Square(Color.blue, Direction.bottom, 0, 2))
        self.game.board.setColor(2, 0, Color.blue)
        self.game.addSquare(Square(Color.red, Direction.left, 2, 3))
        self.game.board.setColor(2, 2, Color.red)
        self.game.addSquare(Square(Color.grey, Direction.right, 1, 1))
        self.game.board.setColor(2, 4, Color.grey)

        self.game.board.setDirection(1, 1, Direction.right)
        self.game.board.setDirection(0, 2, Direction.bottom)
        self.game.board.setDirection(2, 3, Direction.left)
        self.game.board.setDirection(4, 2, Direction.top)

        self.simulator = Simulator(self.game)

    def test_simulation(self):
        print
        print self.game.board
        print self.simulator.find_solution()
开发者ID:haudren,项目名称:squares,代码行数:24,代码来源:tests.py


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