本文整理汇总了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()
示例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()
示例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()