diff options
author | Mitya Selivanov <automainint@guattari.tech> | 2024-07-11 16:31:24 +0200 |
---|---|---|
committer | Mitya Selivanov <automainint@guattari.tech> | 2024-07-11 16:31:24 +0200 |
commit | 1317e9d2334fc9af5055bd8ef6f4064b4469a15b (patch) | |
tree | aaeef3daf12d2814e0495d855b95f77545c45c59 /source/tests | |
parent | 5a0087c5321f89ba48c7a5d664a728bec407c06a (diff) | |
download | kit-1317e9d2334fc9af5055bd8ef6f4064b4469a15b.zip |
Update and fixes for A* search
Diffstat (limited to 'source/tests')
-rw-r--r-- | source/tests/astar.test.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/source/tests/astar.test.c b/source/tests/astar.test.c index 6be9418..f037d65 100644 --- a/source/tests/astar.test.c +++ b/source/tests/astar.test.c @@ -10,7 +10,7 @@ enum { HEIGHT = 5, }; -static astar_link_t neighbor(i8 *grid, i64 a, i64 n) { +static Astar_Link neighbor(i8 *grid, i64 a, i64 n) { i64 x = a % WIDTH; i64 y = a / WIDTH; @@ -23,7 +23,7 @@ static astar_link_t neighbor(i8 *grid, i64 a, i64 n) { else if (n == 3) ++y; else - return (astar_link_t) { + return (Astar_Link) { .stop = 1, }; @@ -31,12 +31,12 @@ static astar_link_t neighbor(i8 *grid, i64 a, i64 n) { if (x < 0 || x >= WIDTH || y < 0 || y >= HEIGHT || m < 0 || m >= WIDTH * HEIGHT || grid[m] == 1) - return (astar_link_t) { + return (Astar_Link) { .stop = 0, .skip = 1, }; - return (astar_link_t) { + return (Astar_Link) { .stop = 0, .skip = 0, .neighbor = m, @@ -68,9 +68,9 @@ static i64 xy(i64 x, i64 y) { } TEST("astar path exists") { - astar_node_t buf[200]; + Astar_Node buf[200]; - astar_set_t sets[2] = { + Astar_Set sets[2] = { { .capacity = 100, .size = 0, .values = buf }, { .capacity = 100, .size = 0, .values = buf + 100 }, }; @@ -83,7 +83,7 @@ TEST("astar path exists") { 1, 1, 0, 0, 0, 0, 0, 0, // }; - astar_state_t state; + Astar_State state; REQUIRE_EQ( astar_init(&state, sets[0], sets[1], grid, xy(0, 0), xy(5, 2)), KIT_OK); @@ -117,9 +117,9 @@ TEST("astar path exists") { } TEST("astar no path") { - astar_node_t buf[200]; + Astar_Node buf[200]; - astar_set_t sets[2] = { + Astar_Set sets[2] = { { .capacity = 100, .size = 0, .values = buf }, { .capacity = 100, .size = 0, .values = buf + 100 }, }; @@ -132,7 +132,7 @@ TEST("astar no path") { 1, 1, 0, 0, 0, 0, 0, 0, // }; - astar_state_t state; + Astar_State state; REQUIRE_EQ( astar_init(&state, sets[0], sets[1], grid, xy(0, 0), xy(5, 2)), KIT_OK); @@ -149,9 +149,9 @@ TEST("astar no path") { } TEST("astar empty path") { - astar_node_t buf[200]; + Astar_Node buf[200]; - astar_set_t sets[2] = { + Astar_Set sets[2] = { { .capacity = 100, .size = 0, .values = buf }, { .capacity = 100, .size = 0, .values = buf + 100 }, }; @@ -164,7 +164,7 @@ TEST("astar empty path") { 1, 1, 0, 0, 0, 0, 0, 0, // }; - astar_state_t state; + Astar_State state; REQUIRE_EQ( astar_init(&state, sets[0], sets[1], grid, xy(4, 3), xy(4, 3)), KIT_OK); |