From 19c810bfe2e4dbb9026a1519880a0fb1fa466bad Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Tue, 19 Jan 2021 14:30:28 +0100 Subject: Fixed astar example. --- examples/stc_astar.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/stc_astar.c b/examples/stc_astar.c index 2d85ee73..6e970a3c 100644 --- a/examples/stc_astar.c +++ b/examples/stc_astar.c @@ -25,7 +25,8 @@ mpoint_init(int x, int y, int width) int mpoint_compare_priority(const MazePoint* a, const MazePoint* b) { - return a->priorty < b->priorty; + // NB! returning 0 gives 14 steps shorter path!? hmm.. + return (a->priorty > b->priorty) - (a->priorty < b->priorty); } int @@ -66,7 +67,7 @@ typedef struct { } MazeStep; using_cdeq(mp, MazePoint, mpoint_compare_priority); -using_cpque(mp, cdeq_mp, <); +using_cpque(mp, cdeq_mp, >); using_csmap(ms, MazePoint, MazePoint, mpoint_key_compare); // step using_csmap(mc, MazePoint, int, mpoint_key_compare); // cost @@ -161,7 +162,7 @@ main(void) printf("length: %zu\n", cdeq_mp_size(path)); c_foreach (it, cdeq_mp, path) - maze.str[mpoint_index(it.ref)] = 't'; + maze.str[mpoint_index(it.ref)] = 'o'; printf("%s", maze.str); cstr_del(&maze); -- cgit v1.2.3