diff options
| author | Kirill Petrashin <kirill8201@yandex.ru> | 2026-03-29 21:55:01 +0300 |
|---|---|---|
| committer | Kirill Petrashin <kirill8201@yandex.ru> | 2026-03-29 21:55:01 +0300 |
| commit | a3d42f5b23df682e3386940b4d92632f9f4c60db (patch) | |
| tree | 76d978280437fd06b076d144407975a3d64ee6c5 /main.c | |
| parent | 2f8fba218e9db6f0835500c49d1b74155c96d43b (diff) | |
| download | astar-a3d42f5b23df682e3386940b4d92632f9f4c60db.tar.xz | |
Implement A*, finally
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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; |
