A* search algorithm: Difference between revisions

Content added Content deleted
Line 970: Line 970:


=={{header|Julia}}==
=={{header|Julia}}==
Unlike some of the examples, the graphic in the solution has its origin in the bottom right.
<lang Julia>using LightGraphs, SimpleWeightedGraphs
<lang Julia>using LightGraphs, SimpleWeightedGraphs


Line 1,003: 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 1:64
for i in 64:-1:1
print(path2graphic(i, path))
print(path2graphic(i, path))
if i % 8 == 0
if i % 8 == 1
println()
println()
end
end
Line 1,013: Line 1,014:
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.......
x..xx...
.x......
.xx..x..
.█████x.
..x.███.
.x█....
....█x.
.x█....
....█x.
.███.x..
.x█████.
..x..xx.
......x.
...xx..x
.......x
</pre>
</pre>