simon-git: puzzles (main): Simon Tatham

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Thu Jun 26 20:42:14 BST 2025


TL;DR:
  eff585c Pearl: make a proper command-line solver.
  8314b03 Pearl: fix shortcut-loop detection on squares.

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:           2025-06-26 20:42:14

commit eff585c0da82598c68bcff21d78277b7417629b8
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=eff585c0da82598c68bcff21d78277b7417629b8;hp=fce4fcb062e2441855b5c22444298b8f6ab6f363
Author: Simon Tatham <anakin at pobox.com>
Date:   Thu Jun 26 17:36:48 2025 +0100

    Pearl: make a proper command-line solver.
    
    The previous binary compiled as 'pearlsolver' was the combined
    benchmark and soak test that CMakeLists.txt was _also_ building under
    the name 'pearlbench'. There wasn't a solver program that you could
    hand a game id to.
    
    Now there is, and 'pearlsolver' is that. 'pearlbench' is unchanged.

 CMakeLists.txt |   2 +-
 pearl.c        | 216 +++++++++++++++++++++++++++++++++++++++++++++------------
 2 files changed, 171 insertions(+), 47 deletions(-)

commit 8314b038070839a2e5358cf10aa7da7f01616cf6
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=8314b038070839a2e5358cf10aa7da7f01616cf6;hp=eff585c0da82598c68bcff21d78277b7417629b8
Author: Simon Tatham <anakin at pobox.com>
Date:   Thu Jun 26 20:20:14 2025 +0100

    Pearl: fix shortcut-loop detection on squares.
    
    The final deduction technique in Tricky mode is to identify a
    particular square and rule out one of the possible states it could be
    in, by observing that that state would connect together two
    already-connected things - hence forming a loop - but the loop would
    be too small to include all the known non-blank squares, and therefore
    couldn't be the true solution.
    
    There were two bugs in this code. One would have made it rule out many
    perfectly sensible square states and conclude that the puzzle had no
    solution, if it hadn't been for the other bug, which prevented the
    code from ever doing anything!
    
    The 'never do anything' bug: in the small sub-loop that looked for the
    common equivalence class of the two neighbouring squares we'd be
    connecting, the output variable 'e' never had a valid value assigned
    to it, because the assignment which should have done that was written
    backwards, 'ee = e' instead of 'e = ee'.
    
    With that fixed, the 'rule out perfectly sensible things' bug became
    visible: if the square is already _known_ to connect a particular pair
    of neighbours together, then it's not interesting that they're in the
    same equivalence class, and doesn't mean we're about to form a loop at
    all!
    
    With both bugs fixed, a test run of 100 puzzle generations in Tricky
    mode, 'pearl --generate 100 8x8dt#12345', generates 18 puzzles
    differently after the change than before. All of those 18 puzzles
    require this now-enabled deduction, and the old Pearl can't solve them
    at all.

 pearl.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)



More information about the tartarus-commits mailing list