Skip to content

Commit 6951d73

Browse files
committed
to resolve issue #2 - incorrect message when destination reached for A*
1 parent 07a30a9 commit 6951d73

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/a_star.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def a_star(win, startEnd, walls):
6262
q_hash.add(coordinate)
6363
q.put((f_score[coordinate], count, coordinate))
6464
win.write('*', *coordinate, fgcolor='green')
65-
pygame.time.wait(5)
65+
pygame.time.wait(1)
6666
if current == end:
6767
count = 0
6868
win.write('@', *end)
@@ -73,13 +73,9 @@ def a_star(win, startEnd, walls):
7373
current = came_from[current]
7474
win.write('+', *current, fgcolor='red')
7575
count += 1
76-
pygame.time.wait(20)
76+
pygame.time.wait(5)
7777
win.write('@', *start)
7878
win.write(f"The shortest path from source to destination has length {count}", 1, 1)
7979
break
80-
win.write("Destination can't be reached from a given source", 1, 1)
81-
82-
83-
84-
85-
80+
if q.empty() and current != end:
81+
win.write("Destination can't be reached from a given source", 1, 1)

0 commit comments

Comments
 (0)