mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00

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.
This is the README accompanying the source code to Simon Tatham's puzzle collection. The collection's web site is at <https://www.chiark.greenend.org.uk/~sgtatham/puzzles/>. The puzzle collection is built using CMake <https://cmake.org/>. To compile in the simplest way (on any of Linux, Windows or Mac), run these commands in the source directory: cmake . cmake --build . The manual is provided in Windows Help format for the Windows build; in text format for anyone who needs it; and in HTML for the Mac OS X application and for the web site. It is generated from a Halibut source file (puzzles.but), which is the preferred form for modification. To generate the manual in other formats, rebuild it, or learn about Halibut, visit the Halibut website at <https://www.chiark.greenend.org.uk/~sgtatham/halibut/>.
Description
Languages
C
93.3%
JavaScript
1.4%
Objective-C
1.1%
CMake
1.1%
HTML
0.8%
Other
2.2%