From 2a9f8b25aaea4385b427ab0a6fc5a4037f669a81 Mon Sep 17 00:00:00 2001 From: Kirill Petrashin Date: Sun, 29 Mar 2026 21:02:43 +0300 Subject: Implement Dijkstra's algorithm --- main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index eded452..317a237 100644 --- a/main.c +++ b/main.c @@ -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; -- cgit v1.2.3