aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Petrashin <kirill8201@yandex.ru>2026-04-24 16:08:22 +0300
committerKirill Petrashin <kirill8201@yandex.ru>2026-04-24 16:08:22 +0300
commit301f4960276d36c75e504ba019031684f45ee1e7 (patch)
treefcda7f153d2db11b5007ba2066a7058e808d4548
parent19a2258299789ba672ce650a56436199c012384d (diff)
downloadastar-301f4960276d36c75e504ba019031684f45ee1e7.tar.xz
Add option to not pathfind on start
-rw-r--r--main.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/main.c b/main.c
index 98093dc..a88825a 100644
--- a/main.c
+++ b/main.c
@@ -70,6 +70,7 @@ int main(int argc, char **argv) {
char is_maze = 0;
char bmp_only = 0;
char *bmp_filename = NULL;
+ char pathfind_on_start = 1;
char anim = 0;
int dirs = 8;
@@ -79,16 +80,18 @@ int main(int argc, char **argv) {
* Currently supported:
* -a to animate the pathfinding (get input after each step)
* -d for Dijkstra
+ * -n to not pathfind on start
* -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
* -4 for four directions
* -8 for eight directions */
int opt;
- while ((opt = getopt(argc, argv, ":adm:f:b:48")) != -1) {
+ while ((opt = getopt(argc, argv, ":adnm:f:b:48")) != -1) {
switch (opt) {
case 'a': anim = 1; break;
case 'd': path_func = &dijkstra_path; break;
+ case 'n': pathfind_on_start = 0; break;
case 'm':
if (sscanf(optarg, "%zux%zu", &mwidth, &mheight) != 2) error("Wrong maze size string in argument\n");
is_maze = 1;
@@ -138,7 +141,8 @@ int main(int argc, char **argv) {
char **visited = visited_new(width, height);
Path path = NULL;
- path = path_func(dirs, map, cell_costs, width, height, start_pos, end_pos, visited, anim);
+ if (pathfind_on_start)
+ path = path_func(dirs, map, cell_costs, 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);