diff options
| author | Kirill Petrashin <kirill8201@yandex.ru> | 2026-03-29 21:02:43 +0300 |
|---|---|---|
| committer | Kirill Petrashin <kirill8201@yandex.ru> | 2026-03-29 21:02:43 +0300 |
| commit | 2a9f8b25aaea4385b427ab0a6fc5a4037f669a81 (patch) | |
| tree | cdcad71ca55a2d9b71ac628556018f594ae92c37 /main.c | |
| parent | 0da3ed44b904b3e5c8d61a236069b2fff1508a7f (diff) | |
| download | astar-2a9f8b25aaea4385b427ab0a6fc5a4037f669a81.tar.xz | |
Implement Dijkstra's algorithm
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -56,6 +56,7 @@ int main(int argc, char **argv) { Position start_pos, end_pos; size_t width, height; Map map = NULL; + Path (*path_func)(int, Map, size_t, size_t, Position, Position, char **, char) = &dijkstra_path; size_t mwidth = 20; /* Maze width */ size_t mheight = 10; /* Maze height */ @@ -134,7 +135,7 @@ int main(int argc, char **argv) { char **visited = visited_new(width, height); Path path = NULL; - path = breadth_first_search_path(dirs, map, width, height, start_pos, end_pos, visited, anim); + path = path_func(dirs, map, width, height, start_pos, end_pos, visited, anim); if (bmp_only) { map_to_bmp(map, width, height, start_pos, end_pos, path, visited, bmp_filename); @@ -174,7 +175,7 @@ int main(int argc, char **argv) { map = rbt_maze_map(mwidth, mheight, rand()); visited = visited_new(width, height); - path = breadth_first_search_path(dirs, map, width, height, start_pos, end_pos, visited, anim); + path = path_func(dirs, map, width, height, start_pos, end_pos, visited, anim); } break; case 's': @@ -188,7 +189,7 @@ int main(int argc, char **argv) { map_free(map, height); map = rbt_maze_map(mwidth, mheight, rand()); path_free(path, height); - path = breadth_first_search_path(dirs, map, width, height, start_pos, end_pos, visited, anim); + path = path_func(dirs, map, width, height, start_pos, end_pos, visited, anim); } break; case 'q': map_free(map, height); path_free(path, height); endwin(); return 0; |
