From da669db4f083194bc78358041c5d9929e103ac9f Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Thu, 24 Oct 2024 21:14:14 +0200 Subject: add more todos, shortcut keys and logging --- DijkstraPathfinder.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'DijkstraPathfinder.cpp') 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) { -- cgit v1.2.3