diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-24 21:14:14 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-24 21:14:14 +0200 |
commit | da669db4f083194bc78358041c5d9929e103ac9f (patch) | |
tree | 3b1b27cac655cb7f852ff4d13233bc278f12ff0f /DijkstraPathfinder.cpp | |
parent | dabfb8188aab86ea8d8c9794ee8e46f6e22291f4 (diff) |
add more todos, shortcut keys and logging
Diffstat (limited to 'DijkstraPathfinder.cpp')
-rw-r--r-- | DijkstraPathfinder.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/DijkstraPathfinder.cpp b/DijkstraPathfinder.cpp index 8d86235..8a8e8eb 100644 --- a/DijkstraPathfinder.cpp +++ b/DijkstraPathfinder.cpp @@ -23,14 +23,19 @@ void DijkstraPathfinder::find_between(const XY & start, const XY & end) { this->map_get(start).distance = 0; this->dijkstra(start); - // no solution - if (!this->is_visited(end)) return; + if (!this->is_visited(end)) { + printf("Dijkstra: no solution found\n"); + return; + } XY pos = end; + int steps = 0; while (pos != start) { solution.push_front(pos); - pos = this->map[pos].parent; + pos = this->map_get(pos).parent; + steps++; } + printf("Dijkstra: solution found (%d steps, %u time)\n", steps, this->map_get(end).distance); } DijkstraPathfinder::Node & DijkstraPathfinder::map_get(const XY & pos) { |