diff options
| author | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-12-25 20:57:45 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano.tronto@gmail.com> | 2021-12-25 20:57:45 +0100 |
| commit | ce4d6f93c8d00a56b9356d0c0d8489c28e1459df (patch) | |
| tree | 4f519efd1850d444ef344f6098b7e3346bcd94a8 /src/commands.c | |
| parent | 0f81a5a70be20a82ee8495f050366a28d0be21c7 (diff) | |
| download | nissy-ce4d6f93c8d00a56b9356d0c0d8489c28e1459df.tar.gz nissy-ce4d6f93c8d00a56b9356d0c0d8489c28e1459df.zip | |
Added -O option for solve (specify number of moves within optimal)
Diffstat (limited to '')
| -rw-r--r-- | src/commands.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/commands.c b/src/commands.c index 7d30c88..56ff944 100644 --- a/src/commands.c +++ b/src/commands.c | |||
| @@ -147,7 +147,7 @@ solve_parse_args(int c, char **v) | |||
| 147 | a->opts->max_moves = 20; | 147 | a->opts->max_moves = 20; |
| 148 | a->opts->max_solutions = 1; | 148 | a->opts->max_solutions = 1; |
| 149 | a->opts->nthreads = 1; | 149 | a->opts->nthreads = 1; |
| 150 | a->opts->optimal_only = false; | 150 | a->opts->optimal = -1; |
| 151 | a->opts->can_niss = false; | 151 | a->opts->can_niss = false; |
| 152 | a->opts->verbose = false; | 152 | a->opts->verbose = false; |
| 153 | a->opts->all = false; | 153 | a->opts->all = false; |
| @@ -163,7 +163,7 @@ solve_parse_args(int c, char **v) | |||
| 163 | if (val < 0 || val > 100) { | 163 | if (val < 0 || val > 100) { |
| 164 | fprintf(stderr, | 164 | fprintf(stderr, |
| 165 | "Invalid min number of moves" | 165 | "Invalid min number of moves" |
| 166 | "(0 <= m <= 100).\n"); | 166 | "(0 <= N <= 100).\n"); |
| 167 | return a; | 167 | return a; |
| 168 | } | 168 | } |
| 169 | a->opts->min_moves = val; | 169 | a->opts->min_moves = val; |
| @@ -172,7 +172,7 @@ solve_parse_args(int c, char **v) | |||
| 172 | if (val < 0 || val > 100) { | 172 | if (val < 0 || val > 100) { |
| 173 | fprintf(stderr, | 173 | fprintf(stderr, |
| 174 | "Invalid max number of moves" | 174 | "Invalid max number of moves" |
| 175 | "(0 <= M <= 100).\n"); | 175 | "(0 <= N <= 100).\n"); |
| 176 | return a; | 176 | return a; |
| 177 | } | 177 | } |
| 178 | a->opts->max_moves = val; | 178 | a->opts->max_moves = val; |
| @@ -196,7 +196,18 @@ solve_parse_args(int c, char **v) | |||
| 196 | a->opts->max_solutions = val; | 196 | a->opts->max_solutions = val; |
| 197 | fixedmsols = true; | 197 | fixedmsols = true; |
| 198 | } else if (!strcmp(v[i], "-o")) { | 198 | } else if (!strcmp(v[i], "-o")) { |
| 199 | a->opts->optimal_only = true; | 199 | a->opts->optimal = 0; |
| 200 | infinitesols = true; | ||
| 201 | } else if (!strcmp(v[i], "-O") && i+1 < c) { | ||
| 202 | val = strtol(v[++i], NULL, 10); | ||
| 203 | if (val < 0 || val > 100 || | ||
| 204 | (val == 0 && strcmp("0", v[i]))) { | ||
| 205 | fprintf(stderr, | ||
| 206 | "Invalid max number of moves" | ||
| 207 | " (0 <= N <= 100).\n"); | ||
| 208 | return a; | ||
| 209 | } | ||
| 210 | a->opts->optimal = val; | ||
| 200 | infinitesols = true; | 211 | infinitesols = true; |
| 201 | } else if (!strcmp(v[i], "-N")) { | 212 | } else if (!strcmp(v[i], "-N")) { |
| 202 | a->opts->can_niss = true; | 213 | a->opts->can_niss = true; |
| @@ -447,7 +458,8 @@ read_scramble(int c, char **v, CommandArgs *args) | |||
| 447 | for(i = 0; i < c; i++) { | 458 | for(i = 0; i < c; i++) { |
| 448 | aux = new_alg(v[i]); | 459 | aux = new_alg(v[i]); |
| 449 | if (aux->len == 0) { | 460 | if (aux->len == 0) { |
| 450 | fprintf(stderr, "Error: %s unrecognized\n", v[i]); | 461 | fprintf(stderr, "Error: %s or its argument" |
| 462 | "unrecognized\n", v[i]); | ||
| 451 | free(aux); | 463 | free(aux); |
| 452 | return false; | 464 | return false; |
| 453 | } | 465 | } |
