Skip to content

Commit 9784461

Browse files
committed
New test with weights instead of walls
1 parent 620f717 commit 9784461

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

tests/test_maze.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,25 @@ def test_maze_1(self):
3131
self.assertTrue( solution == my_solution )
3232

3333

34-
def test_2(self):
34+
def test_weights_instead_of_walls(self):
3535
maze = GridWithWeights(4,4)
3636
walls = []
3737
maze.walls = walls
38-
weights = {(0,0): 3, (0,1):1, (1,1): 4, (2,1):5,(3,1):1,(0,2): 2, (1,2):3, (2,2):3, (3,2): 2}
38+
weights = { (1,1):300, (1,2): 300, (1,3):300}
3939
maze.weights = weights
4040

41-
start = (0,1)
42-
end = (3,1)
41+
start = (0,3)
42+
end = (3,3)
4343

44+
my_solution = [(3, 3), (2, 3), (2, 2), (2, 1),
45+
(2, 0), (1, 0), (0, 0), (0, 1),
46+
(0, 2), (0, 3)]
4447
# Call the A* algorithm and get the frontier
4548
frontier = a_star.a_star_search(graph = maze, start=start, end=end)
46-
maze.draw(width=3, point_to = frontier.visited, start=start, goal=end)
47-
maze.draw(width=3, number = frontier.costs, start=start, goal=end)
48-
print(frontier.visited)
4949

50+
solution = list(backtrack(frontier.visited,start,end))
51+
52+
self.assertTrue( solution == my_solution )
5053

5154
if __name__ == "__main__":
5255
unittest.main()

0 commit comments

Comments
 (0)