Displaying a solver's progress..?

Programs which generate, solve, and analyze Sudoku puzzles

Displaying a solver's progress..?

Postby shakers » Thu Apr 07, 2005 7:50 pm

I was looking at various websites about solving Sudokus and it struck me that there are always several graphics needed to illustrate examples so I began to think about other ways to do it.

I came up with the following - http://www.rmjs.co.uk/sudoku/20050404.htm (I have taken the liberty of using the Times Easy puzzle from 4/4/2005 for the example) as a means of displaying what the text is talking about.

If you hover over the hyperlinks in the reasoning text the relevant cell, row, column or box will be highlighted. If you click on a cell's individual hyperlink it will display its value in the grid.

It still needs some proverbial spit and polish (and a bug fix for Mozilla, but I need to eat this evening!) but I wondered if any of the developers whose programs work on logic might be interested in collaborating to generate a easily useable output to explain the solver's progress...

For the technically minded amongst you, it is all based on JavaScript and CSS. The entire puzzle and clues are passed as variables, and the instructions need relevant the tags putting in to create the links.
shakers
 
Posts: 93
Joined: 10 March 2005

Postby Pappocom » Thu Apr 07, 2005 11:17 pm

Shakers, I haven't had time to study this carefully, but I must say that first impressions are very good indeed!

I must visit again later and study it carefully.

- Wayne.
Pappocom
 
Posts: 599
Joined: 05 March 2005

Postby Guest » Fri Apr 08, 2005 9:11 am

Very neat - and a lot of potential. I'd make two suggestions. Firstly, how about just one hover over in the text, with the other info highlighted by different colours - the relevant digits on the grid could then be coloured appropriately, and the units outlined by a coloured line. This would give all the information at a glance, rather than having to move the mouse all over the place. For instance the first clue could be shown with a bold green 3 in r1c9 (this is the answer), and then r2 & r2c3 could be highlighted in yellow (you could even put a yellow X in r2c7 & r2c9 to show that those two cells are disallowed and why), likewise for r3 and c8 with different colours. As long as there are enough clear colours, I think this would be very effective.

Secondly, how about showing the state of the grid at the point the decision is made, rather than the starting point. So you could click on the text and it would show the known state in black and then have a colour coded explanation of the next move. This way clicking on the links in turn would gradually build up the puzzle to completion.

I noted that the last clue talks about putting a 1 in r1c1 - suspect a buggette here - there is already a 1 in Box 1, and it talks about r9.
Guest
 

Postby shakers » Fri Apr 08, 2005 10:13 am

Thanks for your feedback - I'm still trying to crack the Mozilla bug... it's so good to see "standards" applied so consistenly between browsers!

IJ wrote:Firstly, how about just one hover over in the text, with the other info highlighted by different colours - the relevant digits on the grid could then be coloured appropriately, and the units outlined by a coloured line. This would give all the information at a glance, rather than having to move the mouse all over the place. For instance the first clue could be shown with a bold green 3 in r1c9 (this is the answer), and then r2 & r2c3 could be highlighted in yellow (you could even put a yellow X in r2c7 & r2c9 to show that those two cells are disallowed and why), likewise for r3 and c8 with different colours. As long as there are enough clear colours, I think this would be very effective.


I was thinking about this, and then started thinking about some of the more complicated logic that other solving techniques involve. The amount of highlighting that would be needed for a single hover could potentially be quite large, and possibly confusing in the grid.

The current implementation was meant to be trying to keep it as simple as possible, and just being able to highlight the row, col, etc that's being considered seemed a way forward - especially when compared to many of the online guides that are just plain awkward to read!

The idea of changing the colour of the individual numbers is also very nice, but I think it may present problems with the different browsers - indeed this is the Mozilla problem that currently exists. I'm still trying to maintain a single script, rather than having to write entirely different JS for different browsers.

IJ wrote:Secondly, how about showing the state of the grid at the point the decision is made, rather than the starting point. So you could click on the text and it would show the known state in black and then have a colour coded explanation of the next move. This way clicking on the links in turn would gradually build up the puzzle to completion.


I've given this a little thought, and to be honest I'm not sure how this would be possible. I am not, and have no intention of, writing a solver - which means I'm not keeping track of any moves. It's certainly something to think about though... having written that, I've just had an idea...

IJ wrote:I noted that the last clue talks about putting a 1 in r1c1 - suspect a buggette here - there is already a 1 in Box 1, and it talks about r9.


That was probably me just getting tired and hungry doing the transcription of my moves from my scribbled notes... so a mental buggette, rather than a programmatic one!:)
shakers
 
Posts: 93
Joined: 10 March 2005

Postby shakers » Fri Apr 08, 2005 12:19 pm

shakers wrote:
IJ wrote:Secondly, how about showing the state of the grid at the point the decision is made, rather than the starting point. So you could click on the text and it would show the known state in black and then have a colour coded explanation of the next move. This way clicking on the links in turn would gradually build up the puzzle to completion.


I've given this a little thought, and to be honest I'm not sure how this would be possible. I am not, and have no intention of, writing a solver - which means I'm not keeping track of any moves. It's certainly something to think about though... having written that, I've just had an idea...


http://www.rmjs.co.uk/sudoku/20050404.htm

Idea now implemented:D If you click on 'Update' at the start of the each clue, it takes the grid to its state, unsurprisingly, before the clue is put into play.

I have also sorted out the Mozilla bug:D so I now feel a bit more confident about thinking about highlighting numbers in different colours etc.

It struck me that one of the problems is how the explanatory text would be written: for some more complex puzzles I would consider the elimination of values in a box, row, or col in the case of a pair for example to be a valid step even though it does not result in a cell being filled. I think that if I am going to take this further I need to start talking to someone with a logic solver.

If there's anyone reading this who uses another browser (Safari, Opera, etc), or another OS (I know there are some Mac users here), I'd be interested to know whether it works for them...
shakers
 
Posts: 93
Joined: 10 March 2005

Postby shakers » Fri Apr 08, 2005 1:36 pm

Pappocom wrote:Shakers, I haven't had time to study this carefully, but I must say that first impressions are very good indeed!

I must visit again later and study it carefully.


Thanks for taking the time to have a quick look - I appreciate your initial reactions!

I'd be very interested to hear your thoughts on it when you get a chance.
shakers
 
Posts: 93
Joined: 10 March 2005

Postby Guest » Fri Apr 08, 2005 4:31 pm

I like the update, makes things much clearer further down the list.

It struck me that one of the problems is how the explanatory text would be written


Yes, a tricky one. My solver only uses two rules, and solves all Times puzzles, but these rules depend on pencil marks, and are not really the "intuitive" methods that I use when solving it myself. I don't think these would readily translate into this sort of text without showing the pencil marks (at least not in a helpful way). For instance, the first clue you give, would just be "r1c9 is the only cell in box 3 with a pencil mark for the digit 3". It's a very quick way to solve the puzzle, but not very useful for explaining how!

In fact, I think you'll have a job explaining tricker puzzles without pencil marks anyway - Try explaining that two cells can only be (27), so 2 & 7 can't be anywhere else in a unit. This would be a very long sentence if you had to explain why the digits 1, 3, 5, 6, 8 & 9 can't be in either of those cells! Even worse - that move might not even place a digit, just reduce the possibilities elsewhere. Hmm, I've talked myself into it - you need to show pencil marks. This would certainly make it easier for a solver to produce the output. What do you think?
Guest
 

Postby shakers » Sun Apr 10, 2005 9:55 am

IJ wrote:My solver only uses two rules, and solves all Times puzzles, but these rules depend on pencil marks, and are not really the "intuitive" methods that I use when solving it myself. I don't think these would readily translate into this sort of text without showing the pencil marks (at least not in a helpful way). For instance, the first clue you give, would just be "r1c9 is the only cell in box 3 with a pencil mark for the digit 3". It's a very quick way to solve the puzzle, but not very useful for explaining how!

In fact, I think you'll have a job explaining tricker puzzles without pencil marks anyway - Try explaining that two cells can only be (27), so 2 & 7 can't be anywhere else in a unit. This would be a very long sentence if you had to explain why the digits 1, 3, 5, 6, 8 & 9 can't be in either of those cells! Even worse - that move might not even place a digit, just reduce the possibilities elsewhere. Hmm, I've talked myself into it - you need to show pencil marks. This would certainly make it easier for a solver to produce the output. What do you think?


I think that including the pencil marks is going to be an unrealistic exercise using stylesheets and JavaScript. Keeping track of so many different layers/variables/styles would make the page crawl to a degree that I would question its useability.

To make it more helpful in explaining solving progress I am thinking about being able to highlight multiple columns or rows, and possibly the column and row based on the cell in which they intersect (although I'm not sure how helpful this would be).
shakers
 
Posts: 93
Joined: 10 March 2005

Postby Guest » Sun Apr 10, 2005 8:15 pm

Well, good luck - It's an excellent project.

Some thoughts (because I can never quite shut up), still on the pencil mark ideas, which you should feel free to ignore.

I think colours/highlighting is definitely the way to go for simple situations, but I still feel that some problems are too complex to explain without pencil marks....

I don't know a lot about designing web pages, but wouldn't a table be much easier to manipulate - it wouldn't look as nice, but at least you could just plonk in values on the fly.

You would only have to display the pencil marks relevant to each move, which might make it easier.

Perhaps you could have clues that don't go to a definite digit - such as "r1c1 can only be 1 or 2 because of r1 & c1", with highlighting as discussed. This would leave (12) in r1c1 on the picture. The next clue might be similar for another cell (eg r2c1), and then the third clue would be "r3c2 must be a 3 because of r3, c2 and the restrictions on r1c1 & r2c1". You could then remove the two (12)s. So you'd start with a grid, explain and populate the relevant pencil marks in turn, then show the derived digit and remove the pencil marks. I think that would be clearer that a grid full of pencil marks anyway.

Just ideas to use or ignore as you wish. Like I said - good luck, I look forward to the next version.:)
Guest
 

Postby Pappocom » Sun Apr 10, 2005 10:25 pm

shakers wrote:Thanks for taking the time to have a quick look - I appreciate your initial reactions! I'd be very interested to hear your thoughts on it when you get a chance.

Hello, shakers. I've had another look, and I still like it.

As has been said already, it will be harder to handle the more complex logic - but I'm sure it can be done.

Is the script generated automatically from a given puzzle, or does it require an author to sit down and write it? If the latter, do you aim at the former?

- Wayne
Pappocom
 
Posts: 599
Joined: 05 March 2005

Postby shakers » Mon Apr 11, 2005 7:25 am

Pappocom wrote:As has been said already, it will be harder to handle the more complex logic - but I'm sure it can be done.

Is the script generated automatically from a given puzzle, or does it require an author to sit down and write it? If the latter, do you aim at the former?


These two points are very closely linked, so the answer to the second first.

At present the script has to be written manually as I have no solver to generate the codes. I have no plans to write a solver (there are enough out there), so I would need to collaborate with someone to implement this.

Now to the first point: until I know all of the different types of highlighting that will be needed to indicate the solver's method, it is difficult to sit down and come up with the code to display it.

This also links to my earlier post about how the human readable text would be generated. At present I can highlight a specific cell (referenced as 'xy'), an entire row (ref 'rx'), column (ref 'cy'), or box (ref 'bn'); until I know how the solver will describe its actions I don't really know what other combinations I should allow for.

Likewise, the pencilmarks will, I think, be problematic to reference - what sort of combinations will the solver need to refer to? It's not possible to store lists of all the potential pencilmarks at anyone time, so they would need to be specified when required by the human readable text. Again, this is down to how a solver would work.
shakers
 
Posts: 93
Joined: 10 March 2005

Re: Displaying a solver's progress..?

Postby Tony Williams » Tue Apr 12, 2005 9:02 pm

shakers wrote:It still needs some proverbial spit and polish (and a bug fix for Mozilla, but I need to eat this evening!) but I wondered if any of the developers whose programs work on logic might be interested in collaborating to generate a easily useable output to explain the solver's progress...


Hi Shakers,
I like your display, very good, but beyond the set of software skills that I have. I do have a solver written using EXCEL and VBasic - it currently produces a text Log file, and also an Excel sheet recording each play, and the reasoning behind it.

It should be quite straightforward to organise the EXCEL sheet so that it could be 'parsed' into your format (we might even be able to do this with VBasic in EXCEL). The log file essentially contains 3 types of entries :-

1) Placemnet of Digits, and the rule used (essentialy what you have in your example)

2)Rules for the detection of patterns, Pairs, X-Wings etc

3)Exclusions of digits resulting from 2.

The 'pencil' marks don't appear in the log itself, but I keep these as a separate (parallel) 9x9 grid of 'candidate' digits. The Exclusion entiries in the log (3 above) represent deletions from this matrix - hence we could record into the log, whatever would be needed to power your visulisation tool.

If you e-mail me I would be quite happy to share the EXCEL File and/or provide examples of its outputs (some you may already have seen in these Forums).

I haven't done it yet but I had in mind to write a 'Visualiation' version of the solver to redisplay a solved puzzle step-by-step, but within the EXCEL environment, it would have access to all the available data tables, and log entries, and hence should be an easier problem to solve.

let me know what you think.
Tony Williams
 
Posts: 18
Joined: 02 April 2005

Re: Displaying a solver's progress..?

Postby Tony Williams » Tue Apr 12, 2005 9:19 pm

shakers wrote:I was looking at various websites about solving Sudokus and it struck me that there are always several graphics needed to illustrate examples so I began to think about other ways to do it.

I came up with the following - http://www.rmjs.co.uk/sudoku/20050404.htm (I have taken the liberty of using the Times Easy puzzle from 4/4/2005 for the example) as a means of displaying what the text is talking about.

.


Hi Again,
As an example, here is my log output for the 4/4/05 Puzzle :-
Code: Select all
Move   Rule   Set or Exclude   row   col   Digit   Text
38   Once in Column   Set   2   9   1   Digit  1 Only position in Column( 9) is Cell( 2, 9)
39   Once in Row   Set   6   5   1   Digit  1 Only position in Row( 6) is Cell( 6, 5)
40   Once in Column   Set   9   1   1   Digit  1 Only position in Column( 1) is Cell( 9, 1)
41   Once in Column   Set   2   7   2   Digit  2 Only position in Column( 7) is Cell( 2, 7)
42   Once in SQ   Set   5   2   2   Cell( 5, 2) = 2
43   Once in SQ   Set   7   8   2   Cell( 7, 8) = 2
44   Once in SQ   Set   1   9   3   Cell( 1, 9) = 3
45   Once in SQ   Set   6   4   3   Cell( 6, 4) = 3
46   Once in SQ   Set   7   5   3   Cell( 7, 5) = 3
47   Once in Column   Set   9   7   3   Digit  3 Only position in Column( 7) is Cell( 9, 7)
48   Once in SQ   Set   1   3   4   Cell( 1, 3) = 4
49   Once in Column   Set   2   5   4   Digit  4 Only position in Column( 5) is Cell( 2, 5)
50   Once in SQ   Set   5   6   4   Cell( 5, 6) = 4
51   Once in SQ   Set   8   9   4   Cell( 8, 9) = 4
52   Once in SQ   Set   3   2   5   Cell( 3, 2) = 5
53   Once in SQ   Set   4   7   5   Cell( 4, 7) = 5
54   Once in Row   Set   6   3   5   Digit  5 Only position in Row( 6) is Cell( 6, 3)
55   Once in Row   Set   7   1   5   Digit  5 Only position in Row( 7) is Cell( 7, 1)
56   Once in SQ   Set   9   9   5   Cell( 9, 9) = 5
57   Once in SQ   Set   1   2   6   Cell( 1, 2) = 6
58   Once in Row   Set   3   9   6   Digit  6 Only position in Row( 3) is Cell( 3, 9)
59   Once in SQ   Set   4   5   6   Cell( 4, 5) = 6
60   Once in SQ   Set   5   8   6   Cell( 5, 8) = 6
61   Once in SQ   Set   2   6   7   Cell( 2, 6) = 7
62   Once in Row   Set   5   4   7   Digit  7 Only position in Row( 5) is Cell( 5, 4)
63   Once in SQ   Set   6   8   7   Cell( 6, 8) = 7
64   Once in Column   Set   8   5   7   Digit  7 Only position in Column( 5) is Cell( 8, 5)
65   Once in SQ   Set   9   2   7   Cell( 9, 2) = 7
66   Once in SQ   Set   2   1   8   Cell( 2, 1) = 8
67   Once in Row   Set   7   6   8   Digit  8 Only position in Row( 7) is Cell( 7, 6)
68   Once in Column   Set   8   3   8   Digit  8 Only position in Column( 3) is Cell( 8, 3)
69   Once in SQ   Set   9   8   8   Cell( 9, 8) = 8
70   Once in SQ   Set   1   8   9   Cell( 1, 8) = 9
71   Once in SQ   Set   3   4   9   Cell( 3, 4) = 9
72   Once in Column   Set   4   6   9   Digit  9 Only position in Column( 6) is Cell( 4, 6)
73   Once in SQ   Set   5   3   9   Cell( 5, 3) = 9
74   Once in SQ   Set   8   1   9   Cell( 8, 1) = 9
75   Once in SQ   Set   4   2   1   Cell( 4, 2) = 1
76   Once in SQ   Set   5   7   1   Cell( 5, 7) = 1
77   Once in SQ   Set   1   1   2   Cell( 1, 1) = 2
78   Once in SQ   Set   3   5   2   Cell( 3, 5) = 2
79   Once in SQ   Set   6   6   2   Cell( 6, 6) = 2
80   Once in SQ   Set   8   4   2   Cell( 8, 4) = 2
81   Once in SQ   Set   4   4   8   Cell( 4, 4) = 8


The Text column has wrapped round but otherwise seems OK - of course this contains no RULE or Exclusion entries. I temporarily deleted a Rule that looks to see if the Candiadtes for a Cell are Unique (ie only one Digit that can be placed there) since for this puzzle all placements were 'Unique'.
Tony Williams
 
Posts: 18
Joined: 02 April 2005


Return to Software

cron