Skip to content

Commit 95c5697

Browse files
committed
A few prettiness thingys
1 parent db84bd7 commit 95c5697

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

a_star/tools.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ def _draw_tile(self, point, style, width):
6363
if y2 == y1 - 1:
6464
character = "\u2191"
6565
if 'start' in style and point == style['start']:
66-
character = "S"
66+
character = "S\u00ab"
6767
if 'goal' in style and point == style['goal']:
68-
character = "E"
68+
character = "%s\u00ab" % character
6969
if 'path' in style and point in style['path']:
70-
character = "@"
70+
character = "@%s" % character
7171
if point in self.walls:
72-
character = "#" * width
72+
character = "#" * (width-1)
7373
return character
7474

7575
def draw(self, width=2, **style):

examples/maze_solving_example.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def from_id_width(point, width):
3232
graph.walls = set(WALLS)
3333

3434
# 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),
3636
(4, 3), (4, 4), (4, 5), (4, 6),
3737
(4, 7), (4, 8), (5, 1), (5, 2),
3838
(5, 3), (5, 4), (5, 5), (5, 6),
@@ -42,10 +42,11 @@ def from_id_width(point, width):
4242

4343
# Call the A* algorithm and get the frontier
4444
frontier = a_star.a_star_search(graph = graph, start=(1, 4), end=(7, 8), heuristic=manhattan_distance)
45+
solution = list(frontier.backtrack((7,8)))
4546

4647
# Print the results
4748

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)
4950

5051
print("[costs]")
5152

0 commit comments

Comments
 (0)