shithub: asif

Download patch

ref: c43fe6ddcfe9b0c93572f0042267573e05361bef
parent: e3f2bce8fd80c286f2dba6d063ad1df4d2d0e51d
author: qwx <qwx@sciops.net>
date: Sat Oct 22 17:47:07 EDT 2022

path/*: actually save distance to goal in stats

--- a/path/a∗.c
+++ b/path/a∗.c
@@ -118,6 +118,7 @@
 		zpool = znew(sizeof(PNode));
 	dprint(Logdebug, "grid::a∗findpath: a∗ from [%#p,%P] to [%#p,%P]\n",
 		a, n2p(a), b, n2p(b));
+	stats.dist = distfn(a, b);
 	if((r = a∗(a, b)) < 0)
 		dprint(Logdebug, "grid::a∗findpath: failed to find a path\n");
 	else
--- a/path/bfs.c
+++ b/path/bfs.c
@@ -65,6 +65,7 @@
 	clearpath();
 	dprint(Logdebug, "grid::bfsfindpath: bfs from [%#p,%P] to [%#p,%P]\n",
 		a, n2p(a), b, n2p(b));
+	stats.dist = distfn(a, b);
 	if(bfs(a, b) < 0){
 		dprint(Logdebug, "grid::bfsfindpath: failed to find a path\n");
 		return -1;
--- a/path/dijkstra.c
+++ b/path/dijkstra.c
@@ -113,6 +113,7 @@
 		zpool = znew(sizeof(PNode));
 	dprint(Logdebug, "grid::dijkstrafindpath: dijkstra from [%#p,%P] to [%#p,%P]\n",
 		a, n2p(a), b, n2p(b));
+	stats.dist = distfn(a, b);
 	if((r = dijkstra(a, b)) < 0)
 		dprint(Logdebug, "grid::dijkstrafindpath: failed to find a path\n");
 	else