After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 599867 - rejects valid solutions, bug in hitori_check_rule3
rejects valid solutions, bug in hitori_check_rule3
Status: RESOLVED FIXED
Product: hitori
Classification: Applications
Component: General
git master
Other All
: Normal major
: ---
Assigned To: hitori-maint
hitori-maint
Depends on:
Blocks:
 
 
Reported: 2009-10-28 00:21 UTC by Peter De Wachter
Modified: 2009-11-06 20:41 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
screenshot of the puzzle (47.39 KB, image/png)
2009-10-28 00:21 UTC, Peter De Wachter
  Details
hardcodes this particular puzzle (1.40 KB, patch)
2009-10-28 00:22 UTC, Peter De Wachter
reviewed Details | Review
Alternative rule3 implementation (5.49 KB, patch)
2009-11-04 21:52 UTC, Peter De Wachter
committed Details | Review

Description Peter De Wachter 2009-10-28 00:21:25 UTC
Created attachment 146394 [details]
screenshot of the puzzle

[ This was originally reported in the Debian bug tracking system:
http://bugs.debian.org/552510 ]

See the attached screenshot for the board and a solution that Hitori accepted.
An alternative solution uses the lower '8' in the 7th column. But
hitori_check_rule3 rejects this, it doesn't realize all unpainted cells are
connected. From the debug output:

1 1 1 1 1 1 1 1 
X 1 1 X 1 1 1 1 
2 X 1 1 X 1 1 1 
2 2 X 1 1 X 1 1 
2 2 2 1 1 1 1 1 
2 2 2 1 X 1 X 1 
2 2 2 X 3 X 4 1 
2 2 2 2 3 3 X 1 
group 1 base is 4
group 2 base is 2
group 3 base is 2
group 4 base is 4
** (hitori:24378): DEBUG: Rule 3 failed

I'm not sure exactly where the current algorithm goes wrong. If you want, I can
whip up a patch which replaces it with a simple and stupid floodfill, which
should be good enough for this game.
Comment 1 Peter De Wachter 2009-10-28 00:22:49 UTC
Created attachment 146395 [details] [review]
hardcodes this particular puzzle

I don't know which seed generated this puzzle, so here's a patch which hardcodes it.
Comment 2 Peter De Wachter 2009-11-04 21:52:10 UTC
Created attachment 146955 [details] [review]
Alternative rule3 implementation

This patch replaces hitori_check_rule3 with a simple flood fill based algorithm. This new code works fine.
Comment 3 Philip Withnall 2009-11-05 21:45:30 UTC
(Sorry to take so long to reply. I'm really busy with work, but this is flagged in my mail queue, and I will get to it sometime soon. Thanks for waiting.)
Comment 4 Philip Withnall 2009-11-06 20:41:04 UTC
Thanks. Committed with a few minor changes.

commit a45262e4be1ade9c1737d01a5dd7af3b876fd95a
Author: Philip Withnall <philip@tecnocode.co.uk>
Date:   Fri Nov 6 20:39:10 2009 +0000

    Bug 599867 — rejects valid solutions, bug in hitori_check_rule3
    
    Patch from Peter De Wachter <pdewacht@gmail.com> to reimplement the rule
    3 check as a simple floodfill algorithm, to fix cases where it was
    incorrectly failing. Closes: bgo#599867
    
    Also rename a variable so it doesn't conflict with the time() function.

 src/generator.c |    6 +-
 src/rules.c     |  142 ++++++++++++++++++++++++------------------------------
 2 files changed, 66 insertions(+), 82 deletions(-)