diff options
| author | Tyge Løvset <[email protected]> | 2021-01-19 14:30:28 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-01-19 14:30:28 +0100 |
| commit | 19c810bfe2e4dbb9026a1519880a0fb1fa466bad (patch) | |
| tree | 3b4c7b41c478a1530cc0703174a247d898acef03 | |
| parent | 60132bb5653cf5bd5cf5c0c331bf827456097af5 (diff) | |
| download | STC-modified-19c810bfe2e4dbb9026a1519880a0fb1fa466bad.tar.gz STC-modified-19c810bfe2e4dbb9026a1519880a0fb1fa466bad.zip | |
Fixed astar example.
| -rw-r--r-- | examples/stc_astar.c | 7 |
1 files changed, 4 insertions, 3 deletions
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);
|
