simon-git: puzzles (main): Simon Tatham
Commits to Tartarus hosted VCS
tartarus-commits at lists.tartarus.org
Sun Mar 12 15:27:43 GMT 2023
TL;DR:
28aefee Galaxies: add a missing \n in a diagnostic.
1dfc38c Galaxies: new deduction by counting liberties of exclaves.
08009f3 galaxiessolver: fix soak-test mode.
f018ef9 Galaxies: fix recursion depth limit in solver.
47de8f4 Galaxies: remove the 'maxtries' system.
20f95e3 Galaxies: add some higher Unreasonable presets.
5181878 Galaxies: remove 'solver_recurse_depth' in live use.
adf2a09 Galaxies: skew grid generation in favour of wiggliness.
Repository: https://git.tartarus.org/simon/puzzles.git
On the web: https://git.tartarus.org/?p=simon/puzzles.git
Branch updated: main
Committer: Simon Tatham <anakin at pobox.com>
Date: 2023-03-12 15:27:43
commit 28aefee8fceeb8bd5ea6106eef986284583788dd
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=28aefee8fceeb8bd5ea6106eef986284583788dd;hp=8c5077ee8805e81548b42f093a00f41afdcd4d54
Author: Simon Tatham <anakin at pobox.com>
Date: Sun Mar 12 10:57:53 2023 +0000
Galaxies: add a missing \n in a diagnostic.
galaxies.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
commit 1dfc38c2ec40e726d7dd764cd0176e3bdf5ff008
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=1dfc38c2ec40e726d7dd764cd0176e3bdf5ff008;hp=28aefee8fceeb8bd5ea6106eef986284583788dd
Author: Simon Tatham <anakin at pobox.com>
Date: Sun Mar 12 11:08:26 2023 +0000
Galaxies: new deduction by counting liberties of exclaves.
I've often noticed that Galaxies on 7x7 Unreasonable often generates
puzzles that _I_ don't feel as if I had to use recursion and
backtracking to solve, suggesting that there's an efficient mode of
reasoning available that the puzzle could be using and isn't.
One reason for this is that sometimes Galaxies gives up on trying to
generate an Unreasonable puzzle (if its MAXTRIES counter runs out) and
knowingly falls back to Normal. But that's not the only reason. The
other day I got the puzzle 7x7:gsjgzhfedwgzhd, which Galaxies's own
solver rates as Unreasonable, and I still think it should be Normal.
The full solution to that puzzle is this:
+-+-+-+-+-+-+-+
|y x| o | | |
+ +-+-+-+-+ +o+
| | | | o | |
+ + o + + +-+-+
| | | | | | |
+ +-+-+ +-+o+ +
| o |o| |o|
+ +-+-+ +-+-+ +
| | | | o | |
+ + o + +-+-+-+
| | | | |
+-+-+-+ + +o+ +
| o |x y| |
+-+-+-+-+-+-+-+
and Galaxies's Normal-mode solver gets stuck on it at the point where
it's managed to deduce that the tiles labelled 'x' can't possibly be
associated with any dot other than leftmost dot on the centre row, but
is then unable to figure out that the tiles labelled 'y' must also be
associated with that dot. But clearly they must, because they're boxed
in on all other sides (by the grid edge, and by tiles whose
associations are totally obvious), so if either 'x' tile is to find
_any_ path back to its home dot, it must go through the neighbouring
'y' tile.
So, this commit adds the missing deduction: we use a dsf to identify
'exclaves' (connected sets of tiles all associated to the same dot,
but which do not actually contain the dot), and for each exclave we
count its 'liberties' (unassociated tiles bordering the exclave, i.e.
which would extend the exclave if associated to the same dot). Any
exclave with only one liberty must extend into that tile, or else it
would be cut off completely from its home dot. In this case, each 'x'
tile is an exclave by itself, with 'y' its only liberty. (And once
that deduction is done, the pair {x,y} become a larger exclave, which
can be deduced in the same way to connect to the next tile.)
I think this is a deduction rule simple and obvious enough that it
should go in at Normal mode. I've been using it all along in my own
play, and was surprised to find the game wasn't already taking it into
account. In addition, in a quick cross-test of the two versions,
_most_ 7x7 Normal games generated by the modified Galaxies are still
rated as Normal by the old less powerful solver. So it doesn't extend
the difficulty of Normal mode by very much, if at all.
Another benefit is that this should make Normal puzzles more likely to
contain twisty regions of this type.
Also, of course, the usual effect of adding extra deductions at levels
below Unreasonable means that actually Unreasonable puzzles become
that much more tricky!
I have a couple of ideas for extending this technique to be more
powerful still (filled in as comments at the top of the file). For the
moment, I've just done the most obvious version. Perhaps the others
might need to go in at a higher difficulty level.
galaxies.c | 224 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 220 insertions(+), 4 deletions(-)
commit 08009f3949b5cf6edfd36e904dd8abadb19dd7ba
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=08009f3949b5cf6edfd36e904dd8abadb19dd7ba;hp=1dfc38c2ec40e726d7dd764cd0176e3bdf5ff008
Author: Simon Tatham <anakin at pobox.com>
Date: Sun Mar 12 12:41:23 2023 +0000
galaxiessolver: fix soak-test mode.
It called new_game_desc with aux=NULL. But new_game_desc
unconditionally writes through aux, expecting it to be valid always.
galaxies.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
commit f018ef97d34b9126744e63cc2112c302fcae4ab4
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=f018ef97d34b9126744e63cc2112c302fcae4ab4;hp=08009f3949b5cf6edfd36e904dd8abadb19dd7ba
Author: Simon Tatham <anakin at pobox.com>
Date: Sun Mar 12 14:11:34 2023 +0000
Galaxies: fix recursion depth limit in solver.
The static variable 'solver_recurse_depth' is _mostly_ used by the
standalone solver, to appropriately indent the solver diagnostics for
the current recursion level. So most uses of it are guarded by an
'#ifdef STANDALONE_SOLVER' statement, or some equivalent (such as
being inside the solvep() macro).
One exception is the check that limits the recursion depth to 5, to
avoid getting hung up forever on a too-hard game. Unfortunately, this
check depends on the variable actually incrementing when we recurse
another level - and it wasn't, because the increment itself was under
ifdef! So the generator in live Galaxies could recurse arbitrarily
deep, and generate puzzles that the standalone solver found too hard
_even_ at Unreasonable mode.
Removed the ifdefs, so that solver_recurse_depth is now incremented
and decremented. Also, make sure to initialise the depth to 0 at the
start of a solver run, just in case it had a bogus value left over
from a previous run.
galaxies.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
commit 47de8f449c2a70a6db897e583396afd080bb6157
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=47de8f449c2a70a6db897e583396afd080bb6157;hp=f018ef97d34b9126744e63cc2112c302fcae4ab4
Author: Simon Tatham <anakin at pobox.com>
Date: Sat Mar 11 22:13:52 2023 +0000
Galaxies: remove the 'maxtries' system.
Most games in this collection don't have one. If you ask them for a
hard puzzle, they'll just keep looping round until they actually
manage to deliver one. We try to arrange that the standard presets
don't take too long to generate, but if the user turns up the game
size _and_ uses an expensive difficulty level, our view is that that's
up to them.
After fixing the bug from the previous commit in which the Galaxies
recursion depth limit was not actually doing anything, even 15x15
Unreasonable now generates happily in under a second. So I don't see
any reason why Galaxies should be an exception.
Hence, now if you ask Galaxies for an Unreasonable puzzle, you _will_
get a puzzle that it grades as Unreasonable, even if that takes a long
time to generate.
galaxies.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
commit 20f95e3e223112331ea1b876db82aa8bb2b45e3a
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=20f95e3e223112331ea1b876db82aa8bb2b45e3a;hp=47de8f449c2a70a6db897e583396afd080bb6157
Author: Simon Tatham <anakin at pobox.com>
Date: Sun Mar 12 14:26:45 2023 +0000
Galaxies: add some higher Unreasonable presets.
10x10 and 15x15 Unreasonable are now feasible, so why not include them?
galaxies.c | 2 ++
1 file changed, 2 insertions(+)
commit 51818780f835b459b9671df38eefef06fca3fd89
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=51818780f835b459b9671df38eefef06fca3fd89;hp=20f95e3e223112331ea1b876db82aa8bb2b45e3a
Author: Simon Tatham <anakin at pobox.com>
Date: Sun Mar 12 14:37:36 2023 +0000
Galaxies: remove 'solver_recurse_depth' in live use.
It's horrible to have static mutable state in the live puzzle game.
What if some downstream wanted to run the system in multiple threads?
For purposes of limiting the recursion depth, we now pass an 'int depth'
argument to each call to solver_state_inner(). So in the normal build
of the actual puzzle, the static variable isn't needed at all. We only
include it in binaries that are going to want to use it for printing
indented diagnostics: the CLI solver program, and the live puzzle only
if DEBUGGING is defined. The rest of the time, it's absent.
A side effect of this change is that when the recursion code makes a
guess at a particular tile, the message about that is now indented to
the _outer_ level instead of the inner one, because the previous
'depth++' and 'depth--' statements wrapped the whole loop rather than
just the recursive call to the solver inside. This makes recursive
solving much easier to follow!
galaxies.c | 34 +++++++++++++++++++++-------------
1 file changed, 21 insertions(+), 13 deletions(-)
commit adf2a098298f1aa73aca2c816174d5e63ff45a32
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=adf2a098298f1aa73aca2c816174d5e63ff45a32;hp=51818780f835b459b9671df38eefef06fca3fd89
Author: Simon Tatham <anakin at pobox.com>
Date: Sun Mar 12 15:18:33 2023 +0000
Galaxies: skew grid generation in favour of wiggliness.
Ben complained yesterday that Galaxies had a nasty habit of generating
games whose solution was a boring set of rectangles. Now that even at
Normal mode the solver is better at coping with wiggly tentacled
regions, it seems like a good moment to fix that.
This change arranges that when we initially generate a filled grid, we
try ten times, and pick the wiggliest of the grids we found. This
doesn't make any boring rectangle-filled grid _impossible_ - players
will still have to stay on their toes, and can't rely 100% on at least
a certain number of wiggles existing - but it makes the interesting
grids a lot more likely to come up.
This skew happens before checking solubility. So it doesn't increase
grid generation time by a factor of ten (as it would if we generated
ten _soluble_ grids and picked the wiggliest). It's still a speed
drop, of course, but a more modest one than that.
galaxies.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 79 insertions(+), 12 deletions(-)
More information about the tartarus-commits
mailing list