From a3d42f5b23df682e3386940b4d92632f9f4c60db Mon Sep 17 00:00:00 2001 From: Kirill Petrashin Date: Sun, 29 Mar 2026 21:55:01 +0300 Subject: Implement A*, finally --- main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 317a237..c35afdd 100644 --- a/main.c +++ b/main.c @@ -56,7 +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; + Path (*path_func)(int, Map, size_t, size_t, Position, Position, char **, char) = &astar_path; size_t mwidth = 20; /* Maze width */ size_t mheight = 10; /* Maze height */ @@ -72,6 +72,7 @@ int main(int argc, char **argv) { /* Handle args. * Currently supported: * -a to animate the pathfinding (get input after each step) + * -d for Dijkstra * -m {width}x{height} to give a maze of given size * -f {filename} to load a map from the filename * -b {filename} to just generate a bitmap, no interface @@ -80,9 +81,10 @@ int main(int argc, char **argv) { /* TODO: Argument to choose the algorithm */ /* TODO: Argument to set seed */ int opt; - while ((opt = getopt(argc, argv, ":am:f:b:48")) != -1) { + while ((opt = getopt(argc, argv, ":adm:f:b:48")) != -1) { switch (opt) { case 'a': anim = 1; break; + case 'd': path_func = &dijkstra_path; break; case 'm': if (sscanf(optarg, "%zux%zu", &mwidth, &mheight) != 2) error("Wrong maze size string in argument\n"); is_maze = 1; -- cgit v1.2.3