ref: 59ac8a69af1330a6ea482154b05bc23ec33b594d
parent: 42ec08493a3dc95b6214c0676e4a280a0281ec05
author: Simon Tatham <anakin@pobox.com>
date: Thu Apr 11 15:33:24 EDT 2019
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.
--- a/dominosa.c
+++ b/dominosa.c
@@ -3035,6 +3035,7 @@
game_params *p;
game_state *s, *s2;
char *id = NULL, *desc;
+ int maxdiff = DIFFCOUNT;
const char *err;
bool grade = false, diagnostics = false;
struct solver_scratch *sc;
@@ -3046,6 +3047,21 @@
diagnostics = true;
} else if (!strcmp(p, "-g")) {
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 == '-') {
fprintf(stderr, "%s: unrecognised option `%s'\n", argv[0], p);
return 1;
@@ -3078,7 +3094,7 @@
solver_diagnostics = diagnostics;
sc = solver_make_scratch(p->n);
solver_setup_grid(sc, s->numbers->numbers);
- retd = run_solver(sc, DIFFCOUNT);
+ retd = run_solver(sc, maxdiff);
if (retd == 0) {
printf("Puzzle is inconsistent\n");
} else if (grade) {