diff options
| author | Simon Tatham <anakin@pobox.com> | 2019-04-11 19:39:03 +0100 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2019-04-11 19:39:03 +0100 |
| commit | 1e6e3a815eb67a0d0d369fd0971cf9f3fd9fbf9a (patch) | |
| tree | ae69b44654e971f6ca9d564e86026148ff9ddce6 | |
| parent | 59ac8a69af1330a6ea482154b05bc23ec33b594d (diff) | |
| download | puzzles-1e6e3a815eb67a0d0d369fd0971cf9f3fd9fbf9a.zip puzzles-1e6e3a815eb67a0d0d369fd0971cf9f3fd9fbf9a.tar.gz puzzles-1e6e3a815eb67a0d0d369fd0971cf9f3fd9fbf9a.tar.bz2 puzzles-1e6e3a815eb67a0d0d369fd0971cf9f3fd9fbf9a.tar.xz | |
Dominosa: be more careful about >= Hard layout.
Now we don't just ensure that alloc_try_hard arranged a confounder for
every domino; we also make sure that the full Basic-mode solver can't
place even a single domino with certainty.
| -rw-r--r-- | dominosa.c | 38 |
1 files changed, 37 insertions, 1 deletions
@@ -1916,9 +1916,45 @@ static char *new_game_desc(const game_params *params, random_state *rs, if (!alloc_try_unique(as, rs)) continue; } else { - /* Try to arrange that there is no easy starting point */ + /* + * For Hard puzzles and above, we'd like there not to be + * any easy toehold to start with. + * + * Mostly, that's arranged by alloc_try_hard, which will + * ensure that no domino starts off with only one + * potential placement. But a few other deductions + * possible at Basic level can still sneak through the + * cracks - for example, if the only two placements of one + * domino overlap in a square, and you therefore rule out + * some other domino that can use that square, you might + * then find that _that_ domino now has only one + * placement, and you've made a start. + * + * Of course, the main difficulty-level check will still + * guarantee that you have to do a harder deduction + * _somewhere_ in the grid. But it's more elegant if + * there's nowhere obvious to get started at all. + */ + int di; + bool ok; + if (!alloc_try_hard(as, rs)) continue; + + solver_setup_grid(sc, as->numbers); + if (run_solver(sc, DIFF_BASIC) < 2) + continue; + + ok = true; + for (di = 0; di < sc->dc; di++) + if (sc->dominoes[di].nplacements <= 1) { + ok = false; + break; + } + + if (!ok) { + continue; + } } if (diff != DIFF_AMBIGUOUS) { |