A* search algorithm: Difference between revisions
Content added Content deleted
m (→{{header|Nim}}) |
(Change in the way to write the path in "printSolution".) |
||
Line 1,832: | Line 1,832: | ||
proc printSolution(path: seq[Cell]; cost: int) = |
proc printSolution(path: seq[Cell]; cost: int) = |
||
## Print the solution. |
## Print the solution. |
||
var pathLine = "Path: " |
|||
stdout.write(&"Path: ({path[0].row}, {path[0].col})") |
|||
let start = pathLine.len |
|||
for idx in 1..path.high: |
|||
for cell in path: |
|||
pathLine.addSep(" → ", start) |
|||
pathLine.add(&"({cell.row}, {cell.col})") |
|||
echo |
echo pathLine |
||
echo(&"Cost: {cost}\n\n") |
|||
drawBoard(path) |
drawBoard(path) |
||