Sudoku Programmers Forum Index

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log inLog in          Games  Calendar

Log in to check your private messagesLog in to check your private messages   

Colouring Troubleshooting
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Solving sudoku
View previous topic :: View next topic  
Author Message
gaby

Joined: 02 Jul 2005
Posts: 120
:

Items
PostPosted: Sun Oct 16, 2005 1:32 am    Post subject: Colouring Troubleshooting Reply with quote

Grrrrrr

Right, here are two images:

http://vanhegan.net/pictures/state1.png
http://vanhegan.net/pictures/state1.cols.png

The first is the current state of the puzzle that I have, and the second is how my colouring engine decides to colour the threes. Now, I think that the three colouring combination causes a contradiction in col 6, therefore the 'b' coloured cells can't be right, so the 'a' coloured cells have to be right. So I set the a cells to 3, and a few steps later the puzzle is broken. The puzzle is soluable, and has one solution as I've solved it before. It's just that my colouring is broken.

How would you colour this puzzle? Where have I gone wrong? What rule have I missed out of my colouring algorithgm? Where is this colouring pattern broken?

Gaby
_________________
Free daily sudoku - Online puzzle database
http://vanhegan.net/sudoku/
Back to top
View user's profile Send private message Visit poster's website
Lummox JR

Joined: 07 Sep 2005
Posts: 202
:

Items
PostPosted: Sun Oct 16, 2005 2:22 am    Post subject: Reply with quote

Well, there are two problems. The first is, there's no apparent contradiction in column 6. The light red, yellow, and light green cells can all exist there just fine.

The second problem is, you only found some conjugates, but not all. There is another conjugate in column 8, box 6, between cell (8,4) which is 2b and cell (8,5) which should be 2a.

This leaves you with these exclusions: 4b!2a, 4a!3b, 1b!2a, 1b!3b, g!2a

Unfortunately none of those exclusions lead you anywhere. Transitivity will tell you nothing new, and there are no intersections to be found:

4b and 2a cannot both be true, so at least 4a or 2b must be true. There is no intersection between these colors.
4a and 3b cannot both be true, so at least 4b or 3a must be true. There is no intersection between these colors.
1b and 2a cannot both be true, so at least 1a or 2b must be true. There is no intersection between these colors.
1b and 3b cannot both be true, so at least 1a or 3a must be true. There is no intersection between these colors.
Light green and 2a cannot both be true, so at least green or 2b must be true. There is no intersection between these colors.

There are also no intersections between conjugate colors, since no color pair is spread out far enough to allow the possibility. So there's no coloring you can do on the 3's.
Back to top
View user's profile Send private message
gaby

Joined: 02 Jul 2005
Posts: 120
:

Items
PostPosted: Sun Oct 16, 2005 2:18 pm    Post subject: Reply with quote

The colouring scheme is either the light colours must be true or the dark colours must be true, so the contradiction in column 6 for the light colours means that the light colours can't be true.

Also, I suspect that it found that other conjugate, but it hasn't included it in the colouring map for reasons known only to itself. I think that it's because one part of the conjugate is already used in the yellow set, so I need to make it add that to the yellow set, as it's half yellow already. I think my criteria for including colours is a bit too restrictive. I'll post updated pictures when I've had a chance to work on this today. For the moment, I've got some gardening to do!
_________________
Free daily sudoku - Online puzzle database
http://vanhegan.net/sudoku/
Back to top
View user's profile Send private message Visit poster's website
gaby

Joined: 02 Jul 2005
Posts: 120
:

Items
PostPosted: Sun Oct 16, 2005 8:28 pm    Post subject: Reply with quote

So I made it detect the other conjugate, and label it accordingly, but it still suggests that there is a contradiction in the middle row. If the three conjugates share a common column, then surely only one of them can be true?

http://vanhegan.net/pictures/state2.png

Looking at col 6, the red cells do directly influence the green and yellow colours? Should I only check for contradictions in one state, or both? I can see that if I only check for a state contradictions rather than b state, it'll work. But I can't rely on that. What am I missing here?
_________________
Free daily sudoku - Online puzzle database
http://vanhegan.net/sudoku/
Back to top
View user's profile Send private message Visit poster's website
gaby

Joined: 02 Jul 2005
Posts: 120
:

Items
PostPosted: Sun Oct 16, 2005 8:48 pm    Post subject: Reply with quote

Well, I seem to have made some progress. If I only let it look for contradictions in the a state (all the darker colours numbers) then it seems to work, not generating any false recommendations, and not breaking any puzzles. Also, it looks like it's solving most of those stress testing colouring puzzles that were kindly posted here, bit it's using tabling to do the majority of them, not actually making any progress with colouring.

What on earth is going on here? If I disbable checking for contradictions on the lighter coloured numbers, it works. Surely that shouldn't be the case, as the contradiction in the lighter numbers means that the darkers number should be true?
_________________
Free daily sudoku - Online puzzle database
http://vanhegan.net/sudoku/
Back to top
View user's profile Send private message Visit poster's website
Lummox JR

Joined: 07 Sep 2005
Posts: 202
:

Items
PostPosted: Sun Oct 16, 2005 9:43 pm    Post subject: Reply with quote

gaby wrote:
What on earth is going on here? If I disbable checking for contradictions on the lighter coloured numbers, it works. Surely that shouldn't be the case, as the contradiction in the lighter numbers means that the darkers number should be true?

The mistake you're making here is assuming that the lightness of one color and the darkness of a completely different one are meaningful. The lightness and darkness apply only to one color pair at a time. Red, yellow, and green are not conjugates of each other in any way. If they were, they'd all be red or yellow or green.

It's not that all the light ones must be true or all the dark ones must be true. It's that in the blue colors, the light or dark must be true; in green, the light or dark must be true; and the same in red and yellow. Light blue and dark green can both be true.

In coloring you can only work from the following:

1) A color appears twice in the same house, so it must be false.
2) A color appears alongside two others that are conjugates, so it must be false.
3) A color excludes other colors in such a way that you can prove it excludes itself as well. E.g., a!b -> B!C -> c!a => a!a.
4) A cell appears at the intersection of two conjugates, or of the intersection of the conjugates of two colors that exclude each other.

As I said earlier, there are no coloring opportunities in the 3's in your example.
Back to top
View user's profile Send private message
Ruud
Site Admin
Joined: 17 Sep 2005
Posts: 708
:
Location: Netherlands

Items
PostPosted: Sun Oct 16, 2005 10:29 pm    Post subject: Reply with quote

Don't give up, Gaby!

I had a few errors in my code, and the nature of this complicated stuff sometimes causes weird results. I temporarily rewrote the code to take it one step at the time and show some debugging output after each step. Then I could identify the errors (bad linking of colors, eliminating for the dark in stead of the light colors, etc)


There are still more unrevealed possibilities with colouring.

I've been testing my colouring against some of the puzzles in the multicolor pack posted by Angus, and everything seems to work perfectly now, but still the single-digit-template-checker catches situations faster than colouring.

Here's an example (multi009 from Angus' second pack)
At this point not all clues are placed yet, but the template checker already made a fast elimination.

Code:
. . 5|. 1 .|9 . .
. 4 .|3 . 9|. . .
2 1 9|. 4 .|. . .
-----+-----+-----
. 5 .|6 9 .|. . 7
. . .|. . .|. . .
6 . .|. 8 7|. 9 .
-----+-----+-----
. . .|. 3 .|6 4 9
. . .|5 . 1|. . .
. . .|. . .|. . .


In the next diagram, you see the candidates for digit 7, with colors:
Code:
* * .|* . .|. * .
* . *|. * .|* * .
. . .|* . .|* * .
-----+-----+-----
. . .|. . .|. . .
. A a|. . .|. . .
. . .|. . .|. . .
-----+-----+-----
. B .|b . .|. . .
. * *|. * .|* * .
* * *|. * .|* * .

Now the colouring routine could not draw any conclusions, but the template checker decided to eliminate r2c3. And.... I totally agree with it.

This is the proof: A!B, so either a or b (or both) must be true. When a=true, r2c3 is eliminated. When b=true, r1c4 and r3c4 are eliminated, exposing r2c5 as a single in box 2. The remaining candidates in row 2 will be eliminated, including our victim r2c3.

I've mentioned a couple of similar situations on this forum, but haven't got a lot of feedback. It seems to me that we should not only look at the shared peers of a and b, but also look at the eliminations caused by any of those 2 colors to be true.

Would I still remain in the realm of colouring if I would only check for hidden singles and pointing pairs (ignoring other digits) when testing the a and b colors?
Back to top
View user's profile Send private message Visit poster's website
gaby

Joined: 02 Jul 2005
Posts: 120
:

Items
PostPosted: Sun Oct 16, 2005 10:53 pm    Post subject: Reply with quote

Lummox, the way I have the colouring setup is that the chain of conjugates are coloured appropriately, so either all the light cases should be true (in a forcing chains-style way), or all the dark cases should be true. However, you can only follow the chains that are within the same colour to draw any conclusions. This makes more sense, so I should instruct the solver to test for contradictions one colour at a time, rather than by all the light and dark shades.

As an aside, my solver, using colouring, now ranks this puzzle 2.5.3.2 (the highest numeric value I've seen in my collection, but not the hardest puzzle):

Code:

.........
..6.8....
.1...4.3.
..876..1.
2.....5.3
..3..5..8
9.785....
....7...4
....1.2..


It's a nice tickler, and it uses everything: X-wing, Y-wing, forcing chains, colouring, number pairs, disjoint subsets, and all the simple forms of candidate elimination.
_________________
Free daily sudoku - Online puzzle database
http://vanhegan.net/sudoku/
Back to top
View user's profile Send private message Visit poster's website
gaby

Joined: 02 Jul 2005
Posts: 120
:

Items
PostPosted: Sun Oct 16, 2005 10:56 pm    Post subject: Reply with quote

Oh, and it produces a really pretty colour map for the 9's at one point:

http://vanhegan.net/pictures/state3.png

Quite pleasing to the eye, that one Smile
_________________
Free daily sudoku - Online puzzle database
http://vanhegan.net/sudoku/
Back to top
View user's profile Send private message Visit poster's website
Ruud
Site Admin
Joined: 17 Sep 2005
Posts: 708
:
Location: Netherlands

Items
PostPosted: Sun Oct 16, 2005 11:11 pm    Post subject: Reply with quote

Nice, but not quite there yet.

You do not seem to linkup the conjugate pairs in boxes. Only in rows and columns.
Back to top
View user's profile Send private message Visit poster's website
gaby

Joined: 02 Jul 2005
Posts: 120
:

Items
PostPosted: Sun Oct 16, 2005 11:14 pm    Post subject: Reply with quote

How odd, I though they did. I've seen it in other numbers, just not in the 9's on that particular puzzle. Is there not an example of this in block 6? Light yellow in r4,c7 causes causes dark green (not very dark) in r6,c8? I could provide some sample output from my code, but I think it does. Which one has it missed?
_________________
Free daily sudoku - Online puzzle database
http://vanhegan.net/sudoku/
Back to top
View user's profile Send private message Visit poster's website
Ruud
Site Admin
Joined: 17 Sep 2005
Posts: 708
:
Location: Netherlands

Items
PostPosted: Sun Oct 16, 2005 11:20 pm    Post subject: Reply with quote

Your colouring still looks a bit like this

Your code is missing the conjugate pairs in boxes. e.g. box 3 has a conjugate pair, but it was not colored.
Back to top
View user's profile Send private message Visit poster's website
Lummox JR

Joined: 07 Sep 2005
Posts: 202
:

Items
PostPosted: Sun Oct 16, 2005 11:46 pm    Post subject: Reply with quote

Quote:
Lummox, the way I have the colouring setup is that the chain of conjugates are coloured appropriately, so either all the light cases should be true (in a forcing chains-style way), or all the dark cases should be true. However, you can only follow the chains that are within the same colour to draw any conclusions. This makes more sense, so I should instruct the solver to test for contradictions one colour at a time, rather than by all the light and dark shades.

Exactly my point: Lightness and darkness are relevant only to a single color, and can tell you nothing about other colors. The light shade of one and the dark shade of another could both be true. There are only a few ways to link disparate colors together, as I mentioned, which involves using the exclusions.
Quote:
It's a nice tickler, and it uses everything: X-wing, Y-wing, forcing chains, colouring, number pairs, disjoint subsets, and all the simple forms of candidate elimination.

Again I still think the term Y-wing is a misnomer, and what you really mean is XY-wing. If there's an actual Y-wing method, though, I'd be pleased to learn it.

To elaborate on Ruud's point, too, the 9's will only reveal a single pair of colors. All cells that you have colored can be recolored either light yellow or dark yellow depending on where they fall in the conjugate chain.
Back to top
View user's profile Send private message
Ruud
Site Admin
Joined: 17 Sep 2005
Posts: 708
:
Location: Netherlands

Items
PostPosted: Mon Oct 17, 2005 1:29 am    Post subject: Reply with quote

Lummox JR wrote:
In coloring you can only work from the following:

1) A color appears twice in the same house, so it must be false.
2) A color appears alongside two others that are conjugates, so it must be false.
3) A color excludes other colors in such a way that you can prove it excludes itself as well. E.g., a!b -> B!C -> c!a => a!a.
4) A cell appears at the intersection of two conjugates, or of the intersection of the conjugates of two colors that exclude each other.

To add a little more power to coloring, we could rephrase the last rule:

4) A cell can be eliminated as a candidate when it would be when either of two conjugates were true, or the conjugates of two colors that exclude each other.

This definition does subsume cells at the intersections, but allows the technique to look a little further ahead, past singles and pointing pairs forced by either of the 2 connected colors.

The same definition can be used when checking XY-Wings. That technique is also based on the assumption that one of 2 cells must contain a certain digit.

Another interesting addition: Check XY-Wings before coloring, and designate them in coloring as conjugate pairs. This might produce some eliminations that would otherwise go unnoticed.
Back to top
View user's profile Send private message Visit poster's website
gaby

Joined: 02 Jul 2005
Posts: 120
:

Items
PostPosted: Mon Oct 17, 2005 9:48 pm    Post subject: Reply with quote

OK, I think I licked the problem with that set, in that it was assigning colours to the wrong end. When it was extending a colour with a 2a, it was assigning the conjugate to 2a, when it should have been a 1a...

Alas, I think I have fixed the problem. Now running through the stress test, I found 5 puzzles that don't get solved, and instead come out broken. Disabling colouring cures the problem, so I can only assume it's a problem in there:

This puzzle:

Code:

.9...6..2...2.......2.987..3.9..7.5.54.639.27.7.5..9.1..796.4.......2...9..4...8.


Ends up at this state:

http://vanhegan.net/pictures/state4.png

And suggests removing the dark yellow numbers. Something is not quite right here. Is this a special case? All the other puzzles in the stress testing set got solved fine, most of them with colouring, some without. Where's the error?

I found five more puzzles out of the few hundred that came out broken with my colouring implementation:

Code:

.9...6..2...2.......2.987..3.9..7.5.54.639.27.7.5..9.1..796.4.......2...9..4...8.
2....9..7..3..851..9.5...4......742..5.....3..248......4...1.9..196..2..5..9....4
.8...74.2..3.82..5..2.5..9835....9....6.9.2....9....5453..4.6..6..72.5..9.75...4.
..........67..4.215..7.1.86...18..4.4...3...7.8..49...31.4.8..929.3..57..........
....8..2.52.7.......63..7.5....986...14.6.95...857....6.3..72.......6.37.8..3....


All of these get b0rked in some way by my colouring...
_________________
Free daily sudoku - Online puzzle database
http://vanhegan.net/sudoku/
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Solving sudoku All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Sudoku Programmers topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group

Igloo Theme Version 1.0 :: Created By: Andrew Charron