shithub: asif

Download patch

ref: 366e6a5a214357bee19268314eed9d590f663246
parent: 94c7554f09f3c4b35a7c9c8086426a6abdfa807b
author: qwx <qwx@sciops.net>
date: Wed Jul 6 01:56:30 EDT 2022

app/path: add bfs to algos; lower node size and don't draw .from pointer

--- a/app/path/dat.h
+++ b/app/path/dat.h
@@ -1,7 +1,13 @@
 enum{
-	Nodesz = 8,
+	Nodesz = 4,
 };
 extern Node *selected;
 extern Node *start, *goal;
+
+enum{
+	Pbfs,
+	Pdijkstra,
+	Pa∗,
+};
 
 extern int	(*pathfn)(Node*, Node*);
--- a/app/path/drw.c
+++ b/app/path/drw.c
@@ -140,7 +140,8 @@
 		r.min.y += Nodesz;
 	}
 	drawnodes();
-	drawfrom();
+	if(Nodesz > 8)
+		drawfrom();
 }
 
 static void
--- a/app/path/map.c
+++ b/app/path/map.c
@@ -28,7 +28,9 @@
 	default: sysfatal("setparm: unknown move mode %d", mmode);
 	}
 	switch(alg){
-	case 0: pathfn = a∗findpath; break;
+	case Pa∗: pathfn = a∗findpath; break;
+	case Pbfs: pathfn = bfsfindpath; break;
+	//case Pdijkstra: pathfn = dijkstrafindpath; break;
 	default: sysfatal("setparm: unknown algo type %d", alg);
 	}
 	switch(dist){
--- a/app/path/mkfile
+++ b/app/path/mkfile
@@ -2,8 +2,10 @@
 BIN=$home/bin/$objtype/asif
 TARG=path
 HFILES=../../asif.h ../../path/path.h dat.h fns.h
+#	../../path/dijkstra.$O\
 OFILES=\
 	../../path/a∗.$O\
+	../../path/bfs.$O\
 	../../path/grid.$O\
 	../../dprint.$O\
 	../../emalloc.$O\
@@ -21,6 +23,8 @@
 CFLAGS=$CFLAGS -I../.. -I../../path
 %.$O:	%.c
 	$CC -o $target $CFLAGS $stem.c
+
+#LDFLAGS=$LDFLAGS -p
 
 dicks:V:
 	mkdir -p $BIN
--- a/app/path/path.c
+++ b/app/path/path.c
@@ -108,7 +108,7 @@
 		sysfatal("invalid map size, must be in ]0,512]");
 	keyfn = grkey;
 	mousefn = grmouse;
-	setparm(d, 0, m);
+	setparm(d, Pa∗, m);
 	init(w, h);
 	evloop();
 }