simon-git: puzzles (master): Simon Tatham

Commits to Tartarus hosted VCS tartarus-commits at lists.tartarus.org
Sat May 23 10:32:16 BST 2020


TL;DR:
  8629ef8 groupsolver: show working when using -v on ambiguous puzzles.
  f21d3e4 latin.c: call a user-provided validator function. [NFC]
  31cb522 Group: fill in the latin.c validator function.
  6285c44 Group: hard-mode identity deduction.
  8110518 Keen: fill in the latin.c validator function.
  f2aeda7 Towers: fill in the latin.c validator function.
  66b9e8c Unequal: fill in the latin.c validator function.

Repository:     https://git.tartarus.org/simon/puzzles.git
On the web:     https://git.tartarus.org/?p=simon/puzzles.git
Branch updated: master
Committer:      Simon Tatham <anakin at pobox.com>
Date:           2020-05-23 10:32:16

commit 8629ef8974aa379e578531c4b75ebe8c045286c8
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=8629ef8974aa379e578531c4b75ebe8c045286c8;hp=7acc554805a471103bef0a74e4d64fef945dddb9
Author: Simon Tatham <anakin at pobox.com>
Date:   Fri May 22 19:00:01 2020 +0100

    groupsolver: show working when using -v on ambiguous puzzles.

 unfinished/group.c | 5 +++++
 1 file changed, 5 insertions(+)

commit f21d3e4c74b23380f397a7ee0416928ee971a15d
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=f21d3e4c74b23380f397a7ee0416928ee971a15d;hp=8629ef8974aa379e578531c4b75ebe8c045286c8
Author: Simon Tatham <anakin at pobox.com>
Date:   Sat May 23 08:34:58 2020 +0100

    latin.c: call a user-provided validator function. [NFC]
    
    I've only just realised that there's a false-positive bug in the
    latin.c solver framework.
    
    It's designed to solve puzzles in which the solution is a latin square
    but with some additional constraints provided by the individual
    puzzle, and so during solving, it runs a mixture of its own standard
    deduction functions that apply to any latin-square puzzle and extra
    functions provided by the client puzzle to do deductions based on the
    extra clues or constraints.
    
    But what happens if the _last_ move in the solving process is
    performed by one of the latin.c built-in methods, and it causes a
    violation of the client puzzle's extra constraints? Nothing will ever
    notice, and so the solver will report that the puzzle has a solution
    when it actually has none.
    
    An example is the Group game id 12i:m12b9a1zd9i6d10c3y2l11q4r . This
    was reported by 'groupsolver -g' as being ambiguous. But if you look
    at the two 'solutions' reported in the verbose diagnostics, one of
    them is arrant nonsense: it has no identity element at all, and
    therefore, it fails associativity all over the place. Actually that
    puzzle _does_ have a unique solution.
    
    This bug has been around for ages, and nobody has reported a problem.
    For recursive solving, that's not much of a surprise, because it would
    cause a spurious accusation of ambiguity, so that at generation time
    some valid puzzles would be wrongly discarded, and you'd never see
    them. But at non-recursive levels, I can't see a reason why this bug
    _couldn't_ have led one of the games to present an actually impossible
    puzzle believing it to be soluble.
    
    Possibly this never came up because the other clients of latin.c are
    more forgiving of this error in some way. For example, they might all
    be very likely to use their extra clues early in the solving process,
    so that the requirements are already baked in by the time the final
    grid square is filled. I don't know!
    
    Anyway. The fix is to introduce last-minute client-side validation:
    whenever the centralised latin_solver thinks it's come up with a
    filled grid, it should present it to a puzzle-specific validator
    function and check that it's _really_ a legal solution.
    
    This commit does the plumbing for all of that: it introduces the new
    validator function as one of the many parameters to latin_solver, and
    arranges to call it in an appropriate way during the solving process.
    But all the per-puzzle validation functions are empty, for the moment.

 keen.c             |  7 ++++++-
 latin.c            | 39 ++++++++++++++++++++++++++-------------
 latin.h            |  9 +++++----
 towers.c           |  7 ++++++-
 unequal.c          | 11 +++++++++--
 unfinished/group.c |  7 ++++++-
 6 files changed, 58 insertions(+), 22 deletions(-)

commit 31cb5227e6df543a077910d0f3e7c7e169e7c01e
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=31cb5227e6df543a077910d0f3e7c7e169e7c01e;hp=f21d3e4c74b23380f397a7ee0416928ee971a15d
Author: Simon Tatham <anakin at pobox.com>
Date:   Sat May 23 08:41:43 2020 +0100

    Group: fill in the latin.c validator function.
    
    This actually fixes the example game id mentioned in the previous
    commit. Now 12i:m12b9a1zd9i6d10c3y2l11q4r is reported as Unreasonable
    rather than ambiguous, on the basis that although the solver still
    recurses and finds two filled grids, the validator throws out the
    nonsense one at the last minute, leaving only one that's actually
    legal.

 unfinished/group.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

commit 6285c44610cda5146b11fb1fcda45e488a5504de
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=6285c44610cda5146b11fb1fcda45e488a5504de;hp=31cb5227e6df543a077910d0f3e7c7e169e7c01e
Author: Simon Tatham <anakin at pobox.com>
Date:   Fri May 22 18:57:15 2020 +0100

    Group: hard-mode identity deduction.
    
    This fills in the deduction feature I mentioned in commit 7acc554805,
    of determining the identity by elimination, having ruled out all other
    candidates.
    
    In fact, it goes further: as soon as we know that an element can't be
    the group identity, we rule out every possible entry in its row and
    column which would involve it acting as a left- or right-identity for
    any individual element.
    
    This noticeably increases the number of puzzles that can be solved at
    Hard mode without resorting to Unreasonable-level recursion. In a test
    of 100 Hard puzzles generated with this change, 80 of them are
    reported as Unreasonable by the previous solver.
    
    (One of those puzzles is 12i:m12b9a1zd9i6d10c3y2l11q4r , the example
    case that exposed the latin.c validation bug described by the previous
    two commits. That was reported as ambiguous with the validation bug,
    as Unreasonable with the validation bug fixed, and now it's merely
    Hard, because this identity-based deduction eliminates the need for
    recursion.)

 unfinished/group.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 93 insertions(+), 1 deletion(-)

commit 8110518c33c73ab88838bd537fa085e29b1f7c13
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=8110518c33c73ab88838bd537fa085e29b1f7c13;hp=6285c44610cda5146b11fb1fcda45e488a5504de
Author: Simon Tatham <anakin at pobox.com>
Date:   Sat May 23 09:20:49 2020 +0100

    Keen: fill in the latin.c validator function.
    
    This seems to make no difference that I can detect: a test generation
    run of the form 'keen --generate 1000 6du#12345' outputs an identical
    list of 1000 puzzle ids before and after. So the missing validation in
    this puzzle seems to have been benign.

 keen.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 83 insertions(+), 2 deletions(-)

commit f2aeda71840ff95371e610b0b6b7371f26351a11
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=f2aeda71840ff95371e610b0b6b7371f26351a11;hp=8110518c33c73ab88838bd537fa085e29b1f7c13
Author: Simon Tatham <anakin at pobox.com>
Date:   Sat May 23 10:03:57 2020 +0100

    Towers: fill in the latin.c validator function.
    
    Again, this seems to have made no difference in a test generation run
    with the command "towers --generate 100 6du#12345".

 towers.c | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

commit 66b9e8c7de0eecb3d85d9a1766fab1082848448b
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=66b9e8c7de0eecb3d85d9a1766fab1082848448b;hp=f2aeda71840ff95371e610b0b6b7371f26351a11
Author: Simon Tatham <anakin at pobox.com>
Date:   Sat May 23 10:25:38 2020 +0100

    Unequal: fill in the latin.c validator function.
    
    This too seems to have made no difference: each of the commands
        unequal --generate 1000 6dr#12345
        unequal --generate 1000 6adr#12345
    delivers the same list of puzzles before and after the fix.

 unequal.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 65 insertions(+), 2 deletions(-)



More information about the tartarus-commits mailing list