diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-06 08:01:13 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-11-06 08:01:13 +0100 |
commit | 374a78a264bf351794bb1b2e9973450f151c10d0 (patch) | |
tree | 0df15fea6164968a9455bdd3dbfe788148440130 | |
parent | 0232a84c77097e454cf5f19b2d65796d6b7c76a1 (diff) |
improve dijkstra debug diagnostics
-rw-r--r-- | src/dijkstra.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/dijkstra.cpp b/src/dijkstra.cpp index 7d146ce9..2556dc79 100644 --- a/src/dijkstra.cpp +++ b/src/dijkstra.cpp @@ -211,7 +211,7 @@ path_search_result astar::Dijkstra(world& w, const point from, const point to, o if (auto dist_to_goal = distance_l2(cur_pt, to); dist_to_goal < goal_thres) [[unlikely]] { - auto dist = cur_dist; + auto dist = cur_dist + dist_to_goal; if (auto bb = bbox<float>(bbox_from_pos2(to, cur_pt, own_size)); path_search::is_passable(w, to.chunk3(), bb, own_id, p)) { @@ -305,21 +305,18 @@ path_search_result astar::Dijkstra(world& w, const point from, const point to, o auto d0 = (uint32_t)d0_.length(); char buf[128]; size_t len; + const auto time = result.time() * 1e3f; if (goal_idx != (uint32_t)-1) { auto d = nodes[goal_idx].dist; - len = snformat(buf, "Dijkstra: found time:{:.3} len:{} len0:{} ratio:{:.4}\n"_cf, - result.time()*1e3f, - d, d0, + len = snformat(buf, "Dijkstra: found in {:.3} ms len:{} len0:{} ratio:{:.4}\n"_cf, + time, d, d0, d > 0 && d0 > 0 ? (float)d/(float)d0 : 1); } else { - len = snformat(buf, "Dijkstra: not found closest:{} time:{:.3} len:{} len0:{} ratio:{:.4}\n"_cf, - closest_dist, - result.time()*1e3f, - closest_path_len, - d0, + len = snformat(buf, "Dijkstra: no path found in {:.3} ms closest:{} len:{} len0:{} ratio:{:.4}\n"_cf, + time, closest_dist, closest_path_len, d0, closest_path_len > 0 && d0 > 0 ? (float)closest_path_len/(float)d0 : 1); } std::fwrite(buf, len, 1, stdout); |