mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
Dominosa: max-difficulty option in the solver.
Now, as well as grading a puzzle by the highest difficulty it needed during its solution, I can check _how much_ of a given puzzle is soluble if you remove the higher difficulty levels.
This commit is contained in:
18
dominosa.c
18
dominosa.c
@ -3035,6 +3035,7 @@ int main(int argc, char **argv)
|
|||||||
game_params *p;
|
game_params *p;
|
||||||
game_state *s, *s2;
|
game_state *s, *s2;
|
||||||
char *id = NULL, *desc;
|
char *id = NULL, *desc;
|
||||||
|
int maxdiff = DIFFCOUNT;
|
||||||
const char *err;
|
const char *err;
|
||||||
bool grade = false, diagnostics = false;
|
bool grade = false, diagnostics = false;
|
||||||
struct solver_scratch *sc;
|
struct solver_scratch *sc;
|
||||||
@ -3046,6 +3047,21 @@ int main(int argc, char **argv)
|
|||||||
diagnostics = true;
|
diagnostics = true;
|
||||||
} else if (!strcmp(p, "-g")) {
|
} else if (!strcmp(p, "-g")) {
|
||||||
grade = true;
|
grade = true;
|
||||||
|
} else if (!strncmp(p, "-d", 2) && p[2] && !p[3]) {
|
||||||
|
int i;
|
||||||
|
bool bad = true;
|
||||||
|
for (i = 0; i < lenof(dominosa_diffchars); i++)
|
||||||
|
if (dominosa_diffchars[i] != DIFF_AMBIGUOUS &&
|
||||||
|
dominosa_diffchars[i] == p[2]) {
|
||||||
|
bad = false;
|
||||||
|
maxdiff = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (bad) {
|
||||||
|
fprintf(stderr, "%s: unrecognised difficulty `%c'\n",
|
||||||
|
argv[0], p[2]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
} else if (*p == '-') {
|
} else if (*p == '-') {
|
||||||
fprintf(stderr, "%s: unrecognised option `%s'\n", argv[0], p);
|
fprintf(stderr, "%s: unrecognised option `%s'\n", argv[0], p);
|
||||||
return 1;
|
return 1;
|
||||||
@ -3078,7 +3094,7 @@ int main(int argc, char **argv)
|
|||||||
solver_diagnostics = diagnostics;
|
solver_diagnostics = diagnostics;
|
||||||
sc = solver_make_scratch(p->n);
|
sc = solver_make_scratch(p->n);
|
||||||
solver_setup_grid(sc, s->numbers->numbers);
|
solver_setup_grid(sc, s->numbers->numbers);
|
||||||
retd = run_solver(sc, DIFFCOUNT);
|
retd = run_solver(sc, maxdiff);
|
||||||
if (retd == 0) {
|
if (retd == 0) {
|
||||||
printf("Puzzle is inconsistent\n");
|
printf("Puzzle is inconsistent\n");
|
||||||
} else if (grade) {
|
} else if (grade) {
|
||||||
|
Reference in New Issue
Block a user