A* search algorithm: Difference between revisions

Content added Content deleted
Line 1,004: Line 1,004:


path2graphic(x, path) = (x in obstacles ? '█' : x in path ? 'x' : '.')
path2graphic(x, path) = (x in obstacles ? '█' : x in path ? 'x' : '.')
for i in 64:-1:1
for row in 8:-1:1, col in 7:-1:0
print(path2graphic(i, path))
print(path2graphic(row*8 - col, path))
if i % 8 == 1
if col == 0
println()
println()
end
end
end</lang> {{output}} <pre>
end

</lang> {{output}} <pre>
Solution has cost 11:
Solution has cost 11:
Tuple{Int64,Int64}[(0, 0), (1, 1), (2, 2), (3, 1), (4, 1), (5, 1), (6, 2), (7, 3), (7, 4), (6, 5), (6, 6), (7, 7)]
Tuple{Int64,Int64}[(0, 0), (1, 1), (2, 2), (3, 1), (4, 1), (5, 1), (6, 2), (7, 3), (7, 4), (6, 5), (6, 6), (7, 7)]
x..xx...
...xx..x
.xx..x..
..x..xx.
.x█████.
.█████x.
....█x.
.x█....
....█x.
.x█....
.███.x..
..x.███.
......x.
.x......
.......x
x.......
</pre>
</pre>