Beispiel #1
0
 def test_intermediate_length(self):
     p2 = puzzle.EightPuzzle([0, 1, 2, 4, 3, 5, 7, 6, 8])
     soln = search.graph_search(p2, search.AstarNodes())
     self.assertEqual(len(soln), 18)
Beispiel #2
0
 def test_simple_start(self):
     p3 = puzzle.EightPuzzle([1, 2, 5, 3, 4, 0, 6, 7, 8])
     soln = search.graph_search(p3, search.AstarNodes())
     self.assertEqual(len(soln), 3)
     self.assertEqual(["up", "left", "left"], [a.type for a in soln])
Beispiel #3
0
 def test_is_goal(self):
     initial = [1, 6, 0, 2, 7, 8, 3, 4, 5]
     p = puzzle.EightPuzzle(initial)
     self.assertFalse(p.isGoal(State(initial)))
     self.assertTrue(p.isGoal(State([0, 1, 2, 3, 4, 5, 6, 7, 8])))
Beispiel #4
0
def create():
    return puzzle.EightPuzzle([1, 6, 0, 2, 7, 8, 3, 4, 5])
Beispiel #5
0
 def test_initial_state(self):
     initial = [1, 6, 0, 2, 7, 8, 3, 4, 5]
     p = puzzle.EightPuzzle(initial)
     self.assertEquals(p.initial_state(), State(initial))