@@ -32,7 +32,7 @@ def from_id_width(point, width):
32
32
graph .walls = set (WALLS )
33
33
34
34
# Set the weighs of some points in the maze
35
- graph .weights = {location : random .randint (1 ,10 ) for location in [(3 , 4 ), (3 , 5 ), (4 , 1 ), (4 , 2 ),
35
+ graph .weights = {location : random .randint (1 ,4 ) for location in [(3 , 4 ), (3 , 5 ), (4 , 1 ), (4 , 2 ),
36
36
(4 , 3 ), (4 , 4 ), (4 , 5 ), (4 , 6 ),
37
37
(4 , 7 ), (4 , 8 ), (5 , 1 ), (5 , 2 ),
38
38
(5 , 3 ), (5 , 4 ), (5 , 5 ), (5 , 6 ),
@@ -42,10 +42,11 @@ def from_id_width(point, width):
42
42
43
43
# Call the A* algorithm and get the frontier
44
44
frontier = a_star .a_star_search (graph = graph , start = (1 , 4 ), end = (7 , 8 ), heuristic = manhattan_distance )
45
+ solution = list (frontier .backtrack ((7 ,8 )))
45
46
46
47
# Print the results
47
48
48
- graph .draw (width = 5 , point_to = {k :v .came_from for k ,v in frontier .visited .items ()}, start = (1 , 4 ), goal = (7 , 8 ))
49
+ graph .draw (width = 5 , point_to = {k :v .came_from for k ,v in frontier .visited .items ()}, start = (1 , 4 ), goal = (7 , 8 ), path = solution )
49
50
50
51
print ("[costs]" )
51
52
0 commit comments