aboutsummaryrefslogtreecommitdiff
path: root/towers.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2018-02-26 20:49:57 +0000
committerSimon Tatham <anakin@pobox.com>2018-02-26 20:49:57 +0000
commit2adf0052d66eae88c7a5e55e67fe16e13f7018b5 (patch)
tree1405feb2e9321f8a90d040ee420f5e704282b609 /towers.c
parent2270ee116d2c3ee406cb8c65ac58051664107c42 (diff)
downloadpuzzles-2adf0052d66eae88c7a5e55e67fe16e13f7018b5.zip
puzzles-2adf0052d66eae88c7a5e55e67fe16e13f7018b5.tar.gz
puzzles-2adf0052d66eae88c7a5e55e67fe16e13f7018b5.tar.bz2
puzzles-2adf0052d66eae88c7a5e55e67fe16e13f7018b5.tar.xz
towerssolver: always print solver diagnostics in -v mode.
The branch of the code that claimed the puzzle to be ambiguous was not also re-running the solver with diagnostics enabled, so that if a user tries to use this tool to hand-design a puzzle, they do not get feedback on what the multiple legal solutions actually are.
Diffstat (limited to 'towers.c')
-rw-r--r--towers.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/towers.c b/towers.c
index 9ccc6ae..30ee4cb 100644
--- a/towers.c
+++ b/towers.c
@@ -2072,6 +2072,17 @@ int main(int argc, char **argv)
break;
}
+ if (really_show_working) {
+ /*
+ * Now run the solver again at the last difficulty level we
+ * tried, but this time with diagnostics enabled.
+ */
+ solver_show_working = really_show_working;
+ memcpy(s->grid, s->clues->immutable, p->w * p->w);
+ ret = solver(p->w, s->clues->clues, s->grid,
+ diff < DIFFCOUNT ? diff : DIFFCOUNT-1);
+ }
+
if (diff == DIFFCOUNT) {
if (grade)
printf("Difficulty rating: ambiguous\n");
@@ -2084,9 +2095,6 @@ int main(int argc, char **argv)
else
printf("Difficulty rating: %s\n", towers_diffnames[ret]);
} else {
- solver_show_working = really_show_working;
- memcpy(s->grid, s->clues->immutable, p->w * p->w);
- ret = solver(p->w, s->clues->clues, s->grid, diff);
if (ret != diff)
printf("Puzzle is inconsistent\n");
else