shithub: asif

Download patch

ref: e66c8868c7cf48c23f2c49e2bb933784a1a02d6d
parent: a9376bfb28fbd354131420aafa67fedd1e9a3ca0
author: qwx <qwx@sciops.net>
date: Thu Nov 3 22:19:40 EDT 2022

replace octile distance with chebyshev distance for default movement cost

octile → sqrt2 factor → sqrt2 movement cost on diagonals
chebyshev → 1-factor → cost of 1 on diagonals
+ infinitesimal raise for nicer paths

--- a/app/path/map.c
+++ b/app/path/map.c
@@ -125,9 +125,10 @@
 	case Deuclid: distfn = eucdist; break;
 	case Dmanhattan: distfn = manhdist; break;
 	case Doctile: distfn = octdist; break;
+	case Dchebyshev: distfn = chebdist; break;
 	case -1:
-		distfn = octdist;
-		dprint(Logdebug, "set by default: octile distance\n");
+		distfn = chebdist;
+		dprint(Logdebug, "set by default: chebyshev distance\n");
 		break;
 	default: sysfatal("setparm: unknown distance function %d", dist);
 	}
--- a/app/path/path.c
+++ b/app/path/path.c
@@ -148,8 +148,10 @@
 			d = Doctile;
 		else if(strcmp(s, "manhattan") == 0)
 			d = Dmanhattan;
-		else if(strcmp(s, "euclid") == 0)
+		else if(strcmp(s, "euclidean") == 0)
 			d = Deuclid;
+		else if(strcmp(s, "chebyshev") == 0)
+			d = Dchebyshev;
 		else{
 			fprint(2, "unsupported distance function\n");
 			usage();