aboutsummaryrefslogtreecommitdiff
path: root/shell/shell.c
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-04-17 10:50:57 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-04-17 14:36:27 +0200
commit0ece4b72db22139db51e8f5f37c25f24c84f3e43 (patch)
treefa9d0f5ec4124b2e51194ec6dc888e037b9da7e2 /shell/shell.c
parent785f2859e336db49095a8443be8d204ba0989925 (diff)
downloadnissy-core-0ece4b72db22139db51e8f5f37c25f24c84f3e43.tar.gz
nissy-core-0ece4b72db22139db51e8f5f37c25f24c84f3e43.zip
Small rework of optimal vs maxsols
I wanted to make the "optimal" and "maxsolutions" options mutually exclusive, but in the end I decided there is value in keeping both (e.g. for specifying a limit to the number of solutions when asking for "all" optimal"). Now optimal cannot be negative anymore, for the same reason of maxsolutions. The interface user (shell, UI) will have to take care of handling this in a way that makes sense for the user. Usually this means setting the maximum number of solutions to UINT_MAX (or a similar very high number) when the user wants "all optimal".
Diffstat (limited to '')
-rw-r--r--shell/shell.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/shell/shell.c b/shell/shell.c
index 1ef1a39..2a2720f 100644
--- a/shell/shell.c
+++ b/shell/shell.c
@@ -1,4 +1,5 @@
1#include <inttypes.h> 1#include <inttypes.h>
2#include <limits.h>
2#include <errno.h> 3#include <errno.h>
3#include <stdarg.h> 4#include <stdarg.h>
4#include <stdbool.h> 5#include <stdbool.h>
@@ -482,6 +483,9 @@ solve_exec(args_t *args)
482 return -1; 483 return -1;
483 } 484 }
484 485
486 if (args->maxsolutions == 0)
487 args->maxsolutions = args->optimal >= 0 ? UINT_MAX : 1;
488
485 buf = malloc(size); 489 buf = malloc(size);
486 read = fread(buf, size, 1, file); 490 read = fread(buf, size, 1, file);
487 fclose(file); 491 fclose(file);
@@ -578,8 +582,8 @@ parse_args(int argc, char **argv, args_t *args)
578 .str_nisstype = "", 582 .str_nisstype = "",
579 .minmoves = 0, 583 .minmoves = 0,
580 .maxmoves = 20, 584 .maxmoves = 20,
581 .optimal = -1, 585 .optimal = 20,
582 .maxsolutions = 1, 586 .maxsolutions = 0,
583 .threads = 0, 587 .threads = 0,
584 }; 588 };
585 589

Generated with cgit - Back to sebastiano.tronto.net