Help With Sudoku Explainer

Interactive on-site game threads go here

Re: Help With Sudoku Explainer

Postby 1to9only » Tue Nov 06, 2018 8:41 am

tarek wrote:1. Change the Minimum number of values check (which will give an error if less than 8 on gui)

SukakuExplainer GUI can load a one line sukaku from either file or clipboard [both call the same code!] - works with 0 givens!

tarek wrote:2.Remove APE/ATE from the method hierarchy. Alternatively look at permutations.java and see if there is a way to allow countBits to accept 65-81. The code appears simple enough but will it allow simple changes

Commenting out the APE/ATE code in 'Solver(Grid grid)' constructor in Solver.java is my quickest fix!. Fixing Permutations.java will take more effort.

SukakuExplainer was an interesting coding diversion, I've no current plans to revisit as I don't solve sukakus! I've already built a SukakuExplainerNOAE.jar - I can put this on a free file hosting site for download if you need it fast!!
1to9only
 
Posts: 4073
Joined: 04 April 2018

Re: Help With Sudoku Explainer

Postby tarek » Tue Nov 06, 2018 10:09 am

Hi 1to9only,

No need to repeat exactly what you did. So if handy please post, thanks. I’ll look into permutations.java later on!!!

Tarek
User avatar
tarek
 
Posts: 3759
Joined: 05 January 2006

Re: Help With Sudoku Explainer

Postby 1to9only » Tue Nov 06, 2018 10:26 am

SukakuExplainerNOAE.zip (unzip this for the jar file) can be downloaded here:
http://s000.tinyupload.com/?file_id=00929118684275899320
The file gets deleted from the free file hosting website after (about) 100 days of no activity - when it's gone, it's gone.
Solver.java changes:
Code: Select all
//      addIfWorth(SolvingTechnique.AlignedPairExclusion, indirectHintProducers, new AlignedPairExclusion());
        ...
//      addIfWorth(SolvingTechnique.AlignedTripletExclusion, chainingHintProducers, new AlignedExclusion(3));

[Edit 5 Aug] SukakuExplainerNOAE is now obsolete! see here.
Last edited by 1to9only on Mon Aug 05, 2019 8:18 am, edited 1 time in total.
1to9only
 
Posts: 4073
Joined: 04 April 2018

Re: Help With Sudoku Explainer

Postby tarek » Tue Nov 06, 2018 6:35 pm

Update:

8166 puzzles in the Sukaku puzzle file (V9sukaku-0-X) which solvable up to gsf's sudoku x cycles (FNBTHWX) were successfully rated using NOAE file :D
I will post a sample or 2 to see if the players would like any of these puzzles.

I have an even larger Beyond (FNBTHWX) file which I can filter down to a much smaller file using gsf's sudoku to ED above FNBTHW and solvable with FNBTHWXYKO & rate using NOAE file. The idea is to see if there are any crashes during rating & the result would hopefully be an advanced player sukaku type puzzle


Update2:

the larger 100,000+ puzzles larger Beyond (FNBTHWX) file was shortened using gsf's sudoku to a shorter 32 puzzle file & all successfully rated using NOAE file with ER<9.1 & ED>3.1

Update3:
Here are some the results (all rated with NOAE file):
Code: Select all
V9Sukaku-0-X-00365
.-----------------------------------------------------------------------------------------------.
| 123456789 1345679   12369     | 2345689   123456789 1245678   | 12347     134569    12356789  |
| 1235789   1379      123459    | 2389      12346789  128       | 123567    1379      1235789   |
| 14789     124579    12459     | 12459     5789      235678    | 23567     235679    36789     |
:-----------------------------------------------------------------------------------------------:
| 2456789   4679      124569    | 5689      13456789  4578      | 234567    4679      2456789   |
| 123456789 12346789  34569     | 12356789  123456789 12345789  | 14567     12346789  123456789 |
| 1234568   1346      345678    | 2356      12345679  1245      | 145689    1346      1234568   |
:-----------------------------------------------------------------------------------------------:
| 12347     134578    34578     | 234578    12358     125689    | 15689     15689     12369     |
| 1235789   1379      345789    | 2389      12346789  1278      | 156789    1379      1235789   |
| 123456789 1345679   36789     | 2345689   123456789 1245678   | 14789     1345679   123456789 |
:-----------------------------------------------------------------------------------------------:
1234567891.34567.9123..6..9.23456.8912345678912.45678.1234..7..1.3456..9123.56789123.5.7891.3...7.912345...9.23....891234.678912.....8.123.567..1.3...7.9123.5.7891..4..78912.45.7.912.45...912.45...9....5.789.23.5678..23.567...23.567.9..3..6789.2.456789...4.67.912.456..9....56.891.3456789...45.78..234567.....4.67.9.2.4567891234567891234.6789..3456..9123.5678912345678912345.7891..4567..1234.6789123456789123456.8.1.34.6.....345678..23.56...1234567.912.45....1..456.891.34.6...123456.8.1234..7..1.345.78...345.78..2345.78.123.5..8.12..56.891...56.891...56.89123..6..9123.5.7891.3...7.9..345.789.23....891234.678912....78.1...567891.3...7.9123.5.7891234567891.34567.9..3..6789.23456.8912345678912.45678.1..4..7891.34567.9123456789
ED=6.6/5.0/2.6

V9Sukaku-0-X-00754
.-----------------------------------------------------------------------------------------------.
| 24        12345679  12356789  | 12458     13456     3568      | 123456789 12345679  256       |
| 12345789  2459      12459     | 13459     123456789 13567     | 23567     256       12356789  |
| 123456789 249       12459     | 1234569   123456789 1234567   | 23567     23567     123456789 |
:-----------------------------------------------------------------------------------------------:
| 12456     12579     1245789   | 12468     123456    23468     | 2356789   2379      23456     |
| 12578     12345789  123456789 | 12458     123478    23568     | 235679    134679    2589      |
| 4678      13578     1234578   | 24678     45789     24689     | 1235689   13589     45689     |
:-----------------------------------------------------------------------------------------------:
| 13456789  34578     3457      | 345789    123456789 1456789   | 1689      1569      12345689  |
| 12345789  3458      34578     | 3459      123456789 15679     | 15689     1568      1235789   |
| 458       13456789  12345678  | 24578     4579      5689      | 13456789  13456789  568       |
:-----------------------------------------------------------------------------------------------:
.2.4.....1234567.9123.5678912.45..8.1.3456.....3.56.8.1234567891234567.9.2..56...12345.789.2.45...912.45...91.345...91234567891.3.567...23.567...2..56...123.56789123456789.2.4....912.45...9123456..91234567891234567...23.567...23.567..12345678912.456...12..5.7.912.45.78912.4.6.8.123456....234.6.8..23.56789.23...7.9.23456...12..5.78.12345.78912345678912.45..8.1234..78..23.56.8..23.567.91.34.67.9.2..5..89...4.678.1.3.5.78.12345.78..2.4.678....45.789.2.4.6.89123.56.891.3.5..89...456.891.3456789..345.78...345.7....345.7891234567891..4567891....6.891...56..9123456.8912345.789..345..8...345.78...345...91234567891...567.91...56.891...56.8.123.5.789...45..8.1.345678912345678..2.45.78....45.7.9....56.891.34567891.3456789....56.8.
ED=5.4/5.4/2.6

V9Sukaku-0-X-02169
.-----------------------------------------------------------------------------------------------.
| 124568    134578    345       | 245678    12345679  245689    | 156       135689    234568    |
| 123567    1245689   4569      | 1234567   123468    1234569   | 4567      2345678   123459    |
| 257       2589      12459     | 147       13468     369       | 23567     2578      259       |
:-----------------------------------------------------------------------------------------------:
| 234568    1234578   123       | 12345678  134569    12345689  | 123       1235689   124568    |
| 12345789  124678    12678     | 1235789   123456789 1235789   | 23489     234689    12356789  |
| 245689    1245789   789       | 12456789  1345679   2356789   | 789       2356789   245678    |
:-----------------------------------------------------------------------------------------------:
| 158       2358      4578      | 147       24679     369       | 15689     1258      358       |
| 156789    345678    3456      | 1456789   246789    3456789   | 1456      124689    345789    |
| 245678    124579    459       | 124568    13456789  234568    | 567       235679    245689    |
:-----------------------------------------------------------------------------------------------:
12.456.8.1.345.78...345.....2.45678.1234567.9.2.456.891...56...1.3.56.89.23456.8.123.567..12.456.89...456..91234567..1234.6.8.123456..9...4567...2345678.12345...9.2..5.7...2..5..8912.45...91..4..7..1.34.6.8...3..6..9.23.567...2..5.78..2..5...9.23456.8.12345.78.123......12345678.1.3456..9123456.89123......123.56.8912.456.8.12345.78912.4.678.12...678.123.5.789123456789123.5.789.234...89.234.6.89123.56789.2.456.8912.45.789......78912.4567891.34567.9.23.56789......789.23.56789.2.45678.1...5..8..23.5..8....45.78.1..4..7...2.4.67.9..3..6..91...56.8912..5..8...3.5..8.1...56789..345678...3456...1..456789.2.4.6789..34567891..456...12.4.6.89..345.789.2.45678.12.45.7.9...45...912.456.8.1.3456789.23456.8.....567...23.567.9.2.456.89
ED=7.7/7.7/7.6

V9Sukaku-0-X-03062
.-----------------------------------------------------------------------------------------------.
| 1379      135679    1236789   | 2349      2468      12678     | 1234789   13457     13579     |
| 13789     2346789   3679      | 135789    24689     135789    | 14789     124789    135789    |
| 136789    36789     123456789 | 36789     25789     14789     | 123456789 1478      14678     |
:-----------------------------------------------------------------------------------------------:
| 24679     135679    36789     | 24689     1358      24678     | 14789     134579    24679     |
| 248       234689    34569     | 1567      13579     3459      | 1457      124678    2468      |
| 13468     13569     2369      | 23468     2579      1268      | 12347     134579    13468     |
:-----------------------------------------------------------------------------------------------:
| 1234679   12369     123456789 | 12369     12358     12347     | 123456789 12347     1234679   |
| 123579    234689    12369     | 123579    123468    123579    | 1237      1234678   123579    |
| 13579     135679    1236789   | 23489     246       12678     | 1234789   134579    13579     |
:-----------------------------------------------------------------------------------------------:
1.3...7.91.3.567.9123..6789.234....9.2.4.6.8.12...678.1234..7891.345.7..1.3.5.7.91.3...789.234.6789..3..67.91.3.5.789.2.4.6.891.3.5.7891..4..78912.4..7891.3.5.7891.3..6789..3..6789123456789..3..6789.2..5.7891..4..7891234567891..4..78.1..4.678..2.4.67.91.3.567.9..3..6789.2.4.6.891.3.5..8..2.4.678.1..4..7891.345.7.9.2.4.67.9.2.4...8..234.6.89..3456..91...567..1.3.5.7.9..345...91..45.7..12.4.678..2.4.6.8.1.34.6.8.1.3.56..9.23..6..9.234.6.8..2..5.7.912...6.8.1234..7..1.345.7.91.34.6.8.1234.67.9123..6..9123456789123..6..9123.5..8.1234..7..1234567891234..7..1234.67.9123.5.7.9.234.6.89123..6..9123.5.7.91234.6.8.123.5.7.9123...7..1234.678.123.5.7.91.3.5.7.91.3.567.9123..6789.234...89.2.4.6...12...678.1234..7891.345.7.91.3.5.7.9
ED=7.8/7.8/2.6

V9Sukaku-0-X-03895
.--------------------------------------------------------------------------------------.
| 579      123479   12378    | 123589   134568   12358    | 123789   12367    125679   |
| 12347    24568    45678    | 134579   12358    13569    | 45689    24568    1369     |
| 134679   23568    1245678  | 134679   258      134679   | 12345689 145      13679    |
:--------------------------------------------------------------------------------------:
| 145679   123579   123789   | 1249     2568     23467    | 123789   123579   34679    |
| 125678   4567     456      | 24568    1234679  2468     | 456      3456     234589   |
| 134567   135789   123789   | 234678   2568     124689   | 123789   35789    134569   |
:--------------------------------------------------------------------------------------:
| 134679   25689    12456789 | 34679    258      134679   | 23456789 24578    134679   |
| 134789   24568    12456    | 134579   25789    157      | 2356     256      13679    |
| 14589    134789   123789   | 235789   245679   125789   | 123789   136789   135678   |
:--------------------------------------------------------------------------------------:
....5.7.91234..7.9123...78.123.5..891.3456.8.123.5..8.123...789123..67..12..567.91234..7...2.456.8....45678.1.345.7.9123.5..8.1.3.56..9...456.89.2.456.8.1.3..6..91.34.67.9.23.56.8.12.45678.1.34.67.9.2..5..8.1.34.67.9123456.891..45....1.3..67.91..4567.9123.5.7.9123...78912.4....9.2..56.8..234.67..123...789123.5.7.9..34.67.912..5678....4567.....456....2.456.8.1234.67.9.2.4.6.8....456.....3456....2345..891.34567..1.3.5.789123...789.234.678..2..56.8.12.4.6.89123...789..3.5.7891.3456..91.34.67.9.2..56.8912.456789..34.67.9.2..5..8.1.34.67.9.23456789.2.45.78.1.34.67.91.34..789.2.456.8.12.456...1.345.7.9.2..5.7891...5.7...23.56....2..56...1.3..67.91..45..891.34..789123...789.23.5.789.2.4567.912..5.789123...7891.3..67891.3.5678.
ED=7.1/5.0/2.6

V9Sukaku-0-X-04919
.-----------------------------------------------------------------------------------------------.
| 12345678  134589    3459      | 24567     123456789 124569    | 1567      13578     1245689   |
| 15679     1568      12678     | 24679     123468    249       | 23489     458       234579    |
| 279       13468     123457    | 2579      13468     2579      | 12345689  13468     2579      |
:-----------------------------------------------------------------------------------------------:
| 234578    2349      359       | 1357      13456789  135       | 1567      12678     25689     |
| 123456789 124678    12678     | 12356789  123456789 1235789   | 23489     2389      123456789 |
| 14589     23489     3459      | 1579      134679    3579      | 167       178       278       |
:-----------------------------------------------------------------------------------------------:
| 358       4679      1456789   | 1358      2467      1358      | 2456789   24679     1358      |
| 135678    267       12678     | 13468     246789    1348      | 23489     2459      134589    |
| 12456789  2479      359       | 145689    12345789  345678    | 156       125679    2345678   |
:-----------------------------------------------------------------------------------------------:
12345678.1.345..89..345...9.2.4567..12345678912.456..91...567..1.3.5.78.12.456.891...567.91...56.8.12...678..2.4.67.91234.6.8..2.4....9.234...89...45..8..2345.7.9.2....7.91.34.6.8.12345.7...2..5.7.91.34.6.8..2..5.7.9123456.891.34.6.8..2..5.7.9.2345.78..234....9..3.5...91.3.5.7..1.34567891.3.5....1...567..12...678..2..56.8912345678912.4.678.12...678.123.56789123456789123.5.789.234...89.23....891234567891..45..89.234...89..345...91...5.7.91.34.67.9..3.5.7.91....67..1.....78..2....78...3.5..8....4.67.91..4567891.3.5..8..2.4.67..1.3.5..8..2.456789.2.4.67.91.3.5..8.1.3.5678..2...67..12...678.1.34.6.8..2.4.67891.34...8..234...89.2.45...91.345..8912.456789.2.4..7.9..3.5...91..456.8912345.789..345678.1...56...12..567.9.2345678.
ED=7.6/5.0/2.6


V9Sukaku-0-Xplus-S-00017
.-----------------------------------------------------------------------------------------------.
| 124568    134578    345       | 245678    12345679  245689    | 156       135689    234568    |
| 123567    1245689   4569      | 1234567   123468    123469    | 4567      2345678   123459    |
| 257       2589      12459     | 147       13468     369       | 23567     2578      259       |
:-----------------------------------------------------------------------------------------------:
| 234568    1234578   12        | 12345678  1345679   12345689  | 123       1235689   124568    |
| 12345789  124678    12678     | 1235789   123456789 1235789   | 23489     234689    12356789  |
| 245689    1245789   789       | 12456789  1345679   23456789  | 789       2356789   245678    |
:-----------------------------------------------------------------------------------------------:
| 158       2358      4578      | 147       24679     369       | 15689     1258      358       |
| 156789    345678    3456      | 1456789   246789    3456789   | 1456      124689    345789    |
| 245678    124579    459       | 124568    13456789  234568    | 567       235679    245689    |
:-----------------------------------------------------------------------------------------------:
12.456.8.1.345.78...345.....2.45678.1234567.9.2.456.891...56...1.3.56.89.23456.8.123.567..12.456.89...456..91234567..1234.6.8.1234.6..9...4567...2345678.12345...9.2..5.7...2..5..8912.45...91..4..7..1.34.6.8...3..6..9.23.567...2..5.78..2..5...9.23456.8.12345.78.12.......12345678.1.34567.9123456.89123......123.56.8912.456.8.12345.78912.4.678.12...678.123.5.789123456789123.5.789.234...89.234.6.89123.56789.2.456.8912.45.789......78912.4567891.34567.9.23456789......789.23.56789.2.45678.1...5..8..23.5..8....45.78.1..4..7...2.4.67.9..3..6..91...56.8912..5..8...3.5..8.1...56789..345678...3456...1..456789.2.4.6789..34567891..456...12.4.6.89..345.789.2.45678.12.45.7.9...45...912.456.8.1.3456789.23456.8.....567...23.567.9.2.456.89
ED=7.9/7.9/7.9

V9Sukaku-0-Xplus-S-00022
.-----------------------------------------------------------------------------------------------.
| 12468     35679     12369     | 468       123579    468       | 12347     14579     2468      |
| 35789     1249      124589    | 12359     46789     1237      | 2356789   237       15789     |
| 14789     1234569   12345678  | 12459     5789      23567     | 123456789 123456    36789     |
:-----------------------------------------------------------------------------------------------:
| 268       1457      2459      | 2456      1379      24568     | 23567     35679     248       |
| 134579    23689     34569     | 1379      24568     1379      | 14567     12478     135679    |
| 28        13457     34578     | 24568     1379      24568     | 15689     1359      248       |
:-----------------------------------------------------------------------------------------------:
| 12347     3456789   123456789 | 3478      12358     15689     | 123456789 1456789   12369     |
| 12359     3478      1234578   | 35789     12346     1789      | 1235689   1689      12357     |
| 24678     13569     36789     | 246       135789    46        | 14789     13457     24689     |
:-----------------------------------------------------------------------------------------------:
12.4.6.8...3.567.9123..6..9...4.6.8.123.5.7.9...4.6.8.1234..7..1..45.7.9.2.4.6.8...3.5.78912.4....912.45..89123.5...9...4.6789123...7...23.56789.23...7..1...5.7891..4..789123456..912345678.12.45...9....5.789.23.567..123456789123456.....3..6789.2...6.8.1..45.7...2.45...9.2.456...1.3...7.9.2.456.8..23.567....3.567.9.2.4...8.1.345.7.9.23..6.89..3456..91.3...7.9.2.456.8.1.3...7.91..4567..12.4..78.1.3.567.9.2.....8.1.345.7....345.78..2.456.8.1.3...7.9.2.456.8.1...56.891.3.5...9.2.4...8.1234..7....3456789123456789..34..78.123.5..8.1...56.891234567891..456789123..6..9123.5...9..34..78.12345.78...3.5.7891234.6...1.....789123.56.891....6.89123.5.7...2.4.678.1.3.56..9..3..6789.2.4.6...1.3.5.789...4.6...1..4..7891.345.7...2.4.6.89
ED=9.0/9.0/7.6


tarek
User avatar
tarek
 
Posts: 3759
Joined: 05 January 2006

SudokuExplainer modified to solve/rate 6x6 sudoku puzzles

Postby 1to9only » Wed Jan 02, 2019 10:55 am

This is a custom version of SudokuExplainer modified to solve/rate 6x6 sudoku puzzles with blocks of 2Rx3C, there were some discussions here: http://forum.enjoysudoku.com/hardest-6x6-t35607.html.

Download links are at bottom of this post. Usage is same as per my other hacks of SE!

To invoke the GUI:
Code: Select all
java.exe -jar Sudoku6(2Rx3C)Explainer.jar

Load/Save and Paste/Copy should work with single line (36-chars) or multiple lines (6x6) puzzles. In multiple lines mode, Load and Paste should ignore (!single!) whitespace, inner and outer borders. Save and Copy save 6x6 puzzles with no whitespace. Generate should also work. I've also fixed an annoying feature: on first invokation, the GUI Load... dialog (which opened 'My Documents') now opens the 'current working directory'.

[The multiple lines code is over-engineered and ugly (a comment in the code says so!), and I spent far too much time getting 9x9(3Rx3C) to work in 6x6(2Rx3C) mode, a simpler version would have been: process a 0 or . to denote an empty cell, and a number to denote a given, until the grid is filled.]

To rate a single or bunch of puzzle(s):
Code: Select all
java.exe -Xrs -Xmx500m -cp Sudoku6(2Rx3C)Explainer.jar diuf.sudoku.test.serate --format="%g ED=%r/%p/%d" --input=puzzles.txt --output=puzzles.rated.txt

To display explainer hints (output is to screen, redirect to file if needed):
Code: Select all
java.exe -Xrs -Xmx500m -cp Sudoku6(2Rx3C)Explainer.jar diuf.sudoku.test.hints --input=puzzle.txt

[Edit 11 Jan]
There latest Sukaku6Explainer release can be downloaded: here.

Enjoy!
Last edited by 1to9only on Mon Jan 11, 2021 10:42 am, edited 3 times in total.
1to9only
 
Posts: 4073
Joined: 04 April 2018

SukakuExplainerNOAE

Postby dobrichev » Tue Jul 30, 2019 4:37 pm

Hi 1to9only,

Thanks to your SE modification for pencilmark-only puzzles, a possibly new hardest record can be proven.

Rating first of the Tarek's puzzles of backdoor 6 in singles in batch mode after 47 hours gave ED=20.0/2.3/2.3 which to my knowledge is indication of error.
In GUI mode, after the first few 2.3, series of 2 x 9.1 and about 10-15 x 9.2, the process hangs by repeatedly giving an "empty" next hint.

I would be glad if you manage to do following in the batch processing
- dump the pencilmarks at the time the process identifies its inability to continue and returns ER=20.0;
- possibly extend the hardest technique if it is simply matter of one more recursion or so.

Cheers,
MD
dobrichev
2016 Supporter
 
Posts: 1830
Joined: 24 May 2010

Re: Help With Sudoku Explainer

Postby 1to9only » Tue Jul 30, 2019 9:45 pm

it's been a while since i looked at the SE sukaku code - i'll run it thru the tarek 11 original puzzles with a view to output the pencilmartks after each SE step. it may take a little while to come up with something, as the debugging will be slow - the number of pencilmarks makes SE slow!
1to9only
 
Posts: 4073
Joined: 04 April 2018

SukakuExplainerNOAE pencilmarks

Postby 1to9only » Wed Jul 31, 2019 2:49 pm

I've updated the Hints code (the logical place to make my changes!) to output the pencilmarks BEFORE each SE solving step.

Download the updated SukakuExplainerNOAE.jar (size: 306,733 bytes) from:
http://s000.tinyupload.com/?file_id=06704679737269179102
MD5: 07b5c284211447db37fdd4737c1c102e

[Edit 5 Aug] SukakuExplainerNOAE is now obsolete! see here.

I've put the first of tarek's 11 sukakus from the earlier link posted by MD in a file named puzzle.txt
Code: Select all
..3.5678.1.3456789123456789.23456789...4.678912.4567891234567891.34567891..45.789123.567891.3...7..12345.7..123....891234.678912.4...8.123..6.891........12345.7891234567891234567..12345678.123456.8912345678912345678.123.56.89123456..9123456789.23456789...4.678912.4567891.3.567891.34567891..45.789.234567891..4.678912.456789.23..6.891234.6789123456789123.567891.3...7.912345.789123.567891234.678912.4..78.123456.891234.6...123456789123.56..91234567.91234..7..123456.891234.6...12345678.1234567891...5678912.45678912345678912345678.12.45678..23.567891.3456789123456789123.567891.....7.912.45.789123..6.891234.678912.4..78..23.567891.3...7.912345.789123.56..91234567.9123456789123456.891234.6...12345678.1234567891234567.912345.7..

Usage:
Code: Select all
java.exe -Xrs -Xmx500m -cp SukakuExplainerNOAE.jar diuf.sudoku.test.hints --input=puzzle.txt

The output can be redirected to a file, use Ctrl-C to exit if the program hangs!

Output (up to the point where SukakuExplainerNOAE hangs:):
Hidden Text: Show
Code: Select all
..3.5678.1.3456789123456789.23456789...4.678912.4567891234567891.34567891..45.789123.567891.3...7..12345.7..123....891234.678912.4...8.123..6.891........12345.7891234567891234567..12345678.123456.8912345678912345678.123.56.89123456..9123456789.23456789...4.678912.4567891.3.567891.34567891..45.789.234567891..4.678912.456789.23..6.891234.6789123456789123.567891.3...7.912345.789123.567891234.678912.4..78.123456.891234.6...123456789123.56..91234567.91234..7..123456.891234.6...12345678.1234567891...5678912.45678912345678912345678.12.45678..23.567891.3456789123456789123.567891.....7.912.45.789123..6.891234.678912.4..78..23.567891.3...7.912345.789123.56..91234567.9123456789123456.891234.6...12345678.1234567891234567.912345.7..
+-------------------------------+-------------------------------+-------------------------------+
| 35678     13456789  123456789 | 23456789  46789     12456789  | 123456789 13456789  145789    |
| 12356789  137       123457    | 12389     12346789  1248      | 123689    1         12345789  |
| 123456789 1234567   12345678  | 12345689  123456789 12345678  | 1235689   1234569   123456789 |
+-------------------------------+-------------------------------+-------------------------------+
| 23456789  46789     12456789  | 1356789   13456789  145789    | 23456789  146789    12456789  |
| 23689     12346789  123456789 | 12356789  1379      12345789  | 12356789  12346789  12478     |
| 12345689  12346     123456789 | 123569    12345679  12347     | 12345689  12346     12345678  |
+-------------------------------+-------------------------------+-------------------------------+
| 123456789 156789    12456789  | 123456789 12345678  1245678   | 2356789   13456789  123456789 |
| 12356789  179       1245789   | 123689    12346789  12478     | 2356789   1379      12345789  |
| 123569    12345679  123456789 | 12345689  12346     12345678  | 123456789 12345679  123457    |
+-------------------------------+-------------------------------+-------------------------------+
................1................................................................ 2.3, Naked Single: R2C8: 1
+-------------------------------+-------------------------------+-------------------------------+
| 35678     13456789  123456789 | 23456789  46789     12456789  | 23456789  3456789   45789     |
| 2356789   37        23457     | 2389      2346789   248       | 23689     1         2345789   |
| 123456789 1234567   12345678  | 12345689  123456789 12345678  | 235689    234569    23456789  |
+-------------------------------+-------------------------------+-------------------------------+
| 23456789  46789     12456789  | 1356789   13456789  145789    | 23456789  46789     12456789  |
| 23689     12346789  123456789 | 12356789  1379      12345789  | 12356789  2346789   12478     |
| 12345689  12346     123456789 | 123569    12345679  12347     | 12345689  2346      12345678  |
+-------------------------------+-------------------------------+-------------------------------+
| 123456789 156789    12456789  | 123456789 12345678  1245678   | 2356789   3456789   123456789 |
| 12356789  179       1245789   | 123689    12346789  12478     | 2356789   379       12345789  |
| 123569    12345679  123456789 | 12345689  12346     12345678  | 123456789 2345679   123457    |
+-------------------------------+-------------------------------+-------------------------------+
................1................................................................ 9.1, Double Forcing Chain: R2C9.5 on & off ==> R7C9.5 off
+-------------------------------+-------------------------------+-------------------------------+
| 35678     13456789  123456789 | 23456789  46789     12456789  | 23456789  3456789   45789     |
| 2356789   37        23457     | 2389      2346789   248       | 23689     1         2345789   |
| 123456789 1234567   12345678  | 12345689  123456789 12345678  | 235689    234569    23456789  |
+-------------------------------+-------------------------------+-------------------------------+
| 23456789  46789     12456789  | 1356789   13456789  145789    | 23456789  46789     12456789  |
| 23689     12346789  123456789 | 12356789  1379      12345789  | 12356789  2346789   12478     |
| 12345689  12346     123456789 | 123569    12345679  12347     | 12345689  2346      12345678  |
+-------------------------------+-------------------------------+-------------------------------+
| 123456789 156789    12456789  | 123456789 12345678  1245678   | 2356789   3456789   12346789  |
| 12356789  179       1245789   | 123689    12346789  12478     | 2356789   379       12345789  |
| 123569    12345679  123456789 | 12345689  12346     12345678  | 123456789 2345679   123457    |
+-------------------------------+-------------------------------+-------------------------------+
................1................................................................ 9.1, Double Forcing Chain: R2C9.5 on & off ==> R9C9.5 off
+-------------------------------+-------------------------------+-------------------------------+
| 35678     13456789  123456789 | 23456789  46789     12456789  | 23456789  3456789   45789     |
| 2356789   37        23457     | 2389      2346789   248       | 23689     1         2345789   |
| 123456789 1234567   12345678  | 12345689  123456789 12345678  | 235689    234569    23456789  |
+-------------------------------+-------------------------------+-------------------------------+
| 23456789  46789     12456789  | 1356789   13456789  145789    | 23456789  46789     12456789  |
| 23689     12346789  123456789 | 12356789  1379      12345789  | 12356789  2346789   12478     |
| 12345689  12346     123456789 | 123569    12345679  12347     | 12345689  2346      12345678  |
+-------------------------------+-------------------------------+-------------------------------+
| 123456789 156789    12456789  | 123456789 12345678  1245678   | 2356789   3456789   12346789  |
| 12356789  179       1245789   | 123689    12346789  12478     | 2356789   379       12345789  |
| 123569    12345679  123456789 | 12345689  12346     12345678  | 123456789 2345679   12347     |
+-------------------------------+-------------------------------+-------------------------------+
................1................................................................ 9.2, Double Forcing Chain: R2C9.5 on & off ==> R1C7.5 off
+-------------------------------+-------------------------------+-------------------------------+
| 35678     13456789  123456789 | 23456789  46789     12456789  | 2346789   3456789   45789     |
| 2356789   37        23457     | 2389      2346789   248       | 23689     1         2345789   |
| 123456789 1234567   12345678  | 12345689  123456789 12345678  | 235689    234569    23456789  |
+-------------------------------+-------------------------------+-------------------------------+
| 23456789  46789     12456789  | 1356789   13456789  145789    | 23456789  46789     12456789  |
| 23689     12346789  123456789 | 12356789  1379      12345789  | 12356789  2346789   12478     |
| 12345689  12346     123456789 | 123569    12345679  12347     | 12345689  2346      12345678  |
+-------------------------------+-------------------------------+-------------------------------+
| 123456789 156789    12456789  | 123456789 12345678  1245678   | 2356789   3456789   12346789  |
| 12356789  179       1245789   | 123689    12346789  12478     | 2356789   379       12345789  |
| 123569    12345679  123456789 | 12345689  12346     12345678  | 123456789 2345679   12347     |
+-------------------------------+-------------------------------+-------------------------------+
................1................................................................ 9.2, Double Forcing Chain: R2C9.5 on & off ==> R1C9.5 off
+-------------------------------+-------------------------------+-------------------------------+
| 35678     13456789  123456789 | 23456789  46789     12456789  | 2346789   3456789   4789      |
| 2356789   37        23457     | 2389      2346789   248       | 23689     1         2345789   |
| 123456789 1234567   12345678  | 12345689  123456789 12345678  | 235689    234569    23456789  |
+-------------------------------+-------------------------------+-------------------------------+
| 23456789  46789     12456789  | 1356789   13456789  145789    | 23456789  46789     12456789  |
| 23689     12346789  123456789 | 12356789  1379      12345789  | 12356789  2346789   12478     |
| 12345689  12346     123456789 | 123569    12345679  12347     | 12345689  2346      12345678  |
+-------------------------------+-------------------------------+-------------------------------+
| 123456789 156789    12456789  | 123456789 12345678  1245678   | 2356789   3456789   12346789  |
| 12356789  179       1245789   | 123689    12346789  12478     | 2356789   379       12345789  |
| 123569    12345679  123456789 | 12345689  12346     12345678  | 123456789 2345679   12347     |
+-------------------------------+-------------------------------+-------------------------------+
................1................................................................ 9.2, Double Forcing Chain: R2C9.5 on & off ==> R3C7.5 off
+-------------------------------+-------------------------------+-------------------------------+
| 35678     13456789  123456789 | 23456789  46789     12456789  | 2346789   3456789   4789      |
| 2356789   37        23457     | 2389      2346789   248       | 23689     1         2345789   |
| 123456789 1234567   12345678  | 12345689  123456789 12345678  | 23689     234569    23456789  |
+-------------------------------+-------------------------------+-------------------------------+
| 23456789  46789     12456789  | 1356789   13456789  145789    | 23456789  46789     12456789  |
| 23689     12346789  123456789 | 12356789  1379      12345789  | 12356789  2346789   12478     |
| 12345689  12346     123456789 | 123569    12345679  12347     | 12345689  2346      12345678  |
+-------------------------------+-------------------------------+-------------------------------+
| 123456789 156789    12456789  | 123456789 12345678  1245678   | 2356789   3456789   12346789  |
| 12356789  179       1245789   | 123689    12346789  12478     | 2356789   379       12345789  |
| 123569    12345679  123456789 | 12345689  12346     12345678  | 123456789 2345679   12347     |
+-------------------------------+-------------------------------+-------------------------------+
................1................................................................ 9.2, Double Forcing Chain: R2C9.5 on & off ==> R3C9.5 off
+-------------------------------+-------------------------------+-------------------------------+
| 35678     13456789  123456789 | 23456789  46789     12456789  | 2346789   3456789   4789      |
| 2356789   37        23457     | 2389      2346789   248       | 23689     1         2345789   |
| 123456789 1234567   12345678  | 12345689  123456789 12345678  | 23689     234569    2346789   |
+-------------------------------+-------------------------------+-------------------------------+
| 23456789  46789     12456789  | 1356789   13456789  145789    | 23456789  46789     12456789  |
| 23689     12346789  123456789 | 12356789  1379      12345789  | 12356789  2346789   12478     |
| 12345689  12346     123456789 | 123569    12345679  12347     | 12345689  2346      12345678  |
+-------------------------------+-------------------------------+-------------------------------+
| 123456789 156789    12456789  | 123456789 12345678  1245678   | 2356789   3456789   12346789  |
| 12356789  179       1245789   | 123689    12346789  12478     | 2356789   379       12345789  |
| 123569    12345679  123456789 | 12345689  12346     12345678  | 123456789 2345679   12347     |
+-------------------------------+-------------------------------+-------------------------------+
................1................................................................ 9.2, Double Forcing Chain: R2C9.5 on & off ==> R7C7.5 off
+-------------------------------+-------------------------------+-------------------------------+
| 35678     13456789  123456789 | 23456789  46789     12456789  | 2346789   3456789   4789      |
| 2356789   37        23457     | 2389      2346789   248       | 23689     1         2345789   |
| 123456789 1234567   12345678  | 12345689  123456789 12345678  | 23689     234569    2346789   |
+-------------------------------+-------------------------------+-------------------------------+
| 23456789  46789     12456789  | 1356789   13456789  145789    | 23456789  46789     12456789  |
| 23689     12346789  123456789 | 12356789  1379      12345789  | 12356789  2346789   12478     |
| 12345689  12346     123456789 | 123569    12345679  12347     | 12345689  2346      12345678  |
+-------------------------------+-------------------------------+-------------------------------+
| 123456789 156789    12456789  | 123456789 12345678  1245678   | 236789    3456789   12346789  |
| 12356789  179       1245789   | 123689    12346789  12478     | 2356789   379       12345789  |
| 123569    12345679  123456789 | 12345689  12346     12345678  | 123456789 2345679   12347     |
+-------------------------------+-------------------------------+-------------------------------+
................1................................................................ 9.2, Double Forcing Chain: R2C9.5 on & off ==> R9C7.5 off
+-------------------------------+-------------------------------+-------------------------------+
| 35678     13456789  123456789 | 23456789  46789     12456789  | 2346789   3456789   4789      |
| 2356789   37        23457     | 2389      2346789   248       | 23689     1         2345789   |
| 123456789 1234567   12345678  | 12345689  123456789 12345678  | 23689     234569    2346789   |
+-------------------------------+-------------------------------+-------------------------------+
| 23456789  46789     12456789  | 1356789   13456789  145789    | 23456789  46789     12456789  |
| 23689     12346789  123456789 | 12356789  1379      12345789  | 12356789  2346789   12478     |
| 12345689  12346     123456789 | 123569    12345679  12347     | 12345689  2346      12345678  |
+-------------------------------+-------------------------------+-------------------------------+
| 123456789 156789    12456789  | 123456789 12345678  1245678   | 236789    3456789   12346789  |
| 12356789  179       1245789   | 123689    12346789  12478     | 2356789   379       12345789  |
| 123569    12345679  123456789 | 12345689  12346     12345678  | 12346789  2345679   12347     |
+-------------------------------+-------------------------------+-------------------------------+
................1................................................................ 9.2, Double Forcing Chain: R2C9.5 on & off ==> R7C1.5 off
+-------------------------------+-------------------------------+-------------------------------+
| 35678     13456789  123456789 | 23456789  46789     12456789  | 2346789   3456789   4789      |
| 2356789   37        23457     | 2389      2346789   248       | 23689     1         2345789   |
| 123456789 1234567   12345678  | 12345689  123456789 12345678  | 23689     234569    2346789   |
+-------------------------------+-------------------------------+-------------------------------+
| 23456789  46789     12456789  | 1356789   13456789  145789    | 23456789  46789     12456789  |
| 23689     12346789  123456789 | 12356789  1379      12345789  | 12356789  2346789   12478     |
| 12345689  12346     123456789 | 123569    12345679  12347     | 12345689  2346      12345678  |
+-------------------------------+-------------------------------+-------------------------------+
| 12346789  156789    12456789  | 123456789 12345678  1245678   | 236789    3456789   12346789  |
| 12356789  179       1245789   | 123689    12346789  12478     | 2356789   379       12345789  |
| 123569    12345679  123456789 | 12345689  12346     12345678  | 12346789  2345679   12347     |
+-------------------------------+-------------------------------+-------------------------------+
................1................................................................ 9.2, Double Forcing Chain: R2C9.5 on & off ==> R9C3.5 off
+-------------------------------+-------------------------------+-------------------------------+
| 35678     13456789  123456789 | 23456789  46789     12456789  | 2346789   3456789   4789      |
| 2356789   37        23457     | 2389      2346789   248       | 23689     1         2345789   |
| 123456789 1234567   12345678  | 12345689  123456789 12345678  | 23689     234569    2346789   |
+-------------------------------+-------------------------------+-------------------------------+
| 23456789  46789     12456789  | 1356789   13456789  145789    | 23456789  46789     12456789  |
| 23689     12346789  123456789 | 12356789  1379      12345789  | 12356789  2346789   12478     |
| 12345689  12346     123456789 | 123569    12345679  12347     | 12345689  2346      12345678  |
+-------------------------------+-------------------------------+-------------------------------+
| 12346789  156789    12456789  | 123456789 12345678  1245678   | 236789    3456789   12346789  |
| 12356789  179       1245789   | 123689    12346789  12478     | 2356789   379       12345789  |
| 123569    12345679  12346789  | 12345689  12346     12345678  | 12346789  2345679   12347     |
+-------------------------------+-------------------------------+-------------------------------+
................1................................................................ 9.2, Double Forcing Chain: R2C9.5 on & off ==> R9C1.5 off
+-------------------------------+-------------------------------+-------------------------------+
| 35678     13456789  123456789 | 23456789  46789     12456789  | 2346789   3456789   4789      |
| 2356789   37        23457     | 2389      2346789   248       | 23689     1         2345789   |
| 123456789 1234567   12345678  | 12345689  123456789 12345678  | 23689     234569    2346789   |
+-------------------------------+-------------------------------+-------------------------------+
| 23456789  46789     12456789  | 1356789   13456789  145789    | 23456789  46789     12456789  |
| 23689     12346789  123456789 | 12356789  1379      12345789  | 12356789  2346789   12478     |
| 12345689  12346     123456789 | 123569    12345679  12347     | 12345689  2346      12345678  |
+-------------------------------+-------------------------------+-------------------------------+
| 12346789  156789    12456789  | 123456789 12345678  1245678   | 236789    3456789   12346789  |
| 12356789  179       1245789   | 123689    12346789  12478     | 2356789   379       12345789  |
| 12369     12345679  12346789  | 12345689  12346     12345678  | 12346789  2345679   12347     |
+-------------------------------+-------------------------------+-------------------------------+
................1................................................................ 9.2, Double Forcing Chain: R2C9.5 on & off ==> R7C3.5 off
+-------------------------------+-------------------------------+-------------------------------+
| 35678     13456789  123456789 | 23456789  46789     12456789  | 2346789   3456789   4789      |
| 2356789   37        23457     | 2389      2346789   248       | 23689     1         2345789   |
| 123456789 1234567   12345678  | 12345689  123456789 12345678  | 23689     234569    2346789   |
+-------------------------------+-------------------------------+-------------------------------+
| 23456789  46789     12456789  | 1356789   13456789  145789    | 23456789  46789     12456789  |
| 23689     12346789  123456789 | 12356789  1379      12345789  | 12356789  2346789   12478     |
| 12345689  12346     123456789 | 123569    12345679  12347     | 12345689  2346      12345678  |
+-------------------------------+-------------------------------+-------------------------------+
| 12346789  156789    1246789   | 123456789 12345678  1245678   | 236789    3456789   12346789  |
| 12356789  179       1245789   | 123689    12346789  12478     | 2356789   379       12345789  |
| 12369     12345679  12346789  | 12345689  12346     12345678  | 12346789  2345679   12347     |
+-------------------------------+-------------------------------+-------------------------------+
................1................................................................ 9.2, Double Forcing Chain: R2C9.5 on & off ==> R3C3.5 off
+-------------------------------+-------------------------------+-------------------------------+
| 35678     13456789  123456789 | 23456789  46789     12456789  | 2346789   3456789   4789      |
| 2356789   37        23457     | 2389      2346789   248       | 23689     1         2345789   |
| 123456789 1234567   1234678   | 12345689  123456789 12345678  | 23689     234569    2346789   |
+-------------------------------+-------------------------------+-------------------------------+
| 23456789  46789     12456789  | 1356789   13456789  145789    | 23456789  46789     12456789  |
| 23689     12346789  123456789 | 12356789  1379      12345789  | 12356789  2346789   12478     |
| 12345689  12346     123456789 | 123569    12345679  12347     | 12345689  2346      12345678  |
+-------------------------------+-------------------------------+-------------------------------+
| 12346789  156789    1246789   | 123456789 12345678  1245678   | 236789    3456789   12346789  |
| 12356789  179       1245789   | 123689    12346789  12478     | 2356789   379       12345789  |
| 12369     12345679  12346789  | 12345689  12346     12345678  | 12346789  2345679   12347     |
+-------------------------------+-------------------------------+-------------------------------+
................1................................................................ 9.2, Double Forcing Chain: R2C9.5 on & off ==> R1C3.5 off
+-------------------------------+-------------------------------+-------------------------------+
| 35678     13456789  12346789  | 23456789  46789     12456789  | 2346789   3456789   4789      |
| 2356789   37        23457     | 2389      2346789   248       | 23689     1         2345789   |
| 123456789 1234567   1234678   | 12345689  123456789 12345678  | 23689     234569    2346789   |
+-------------------------------+-------------------------------+-------------------------------+
| 23456789  46789     12456789  | 1356789   13456789  145789    | 23456789  46789     12456789  |
| 23689     12346789  123456789 | 12356789  1379      12345789  | 12356789  2346789   12478     |
| 12345689  12346     123456789 | 123569    12345679  12347     | 12345689  2346      12345678  |
+-------------------------------+-------------------------------+-------------------------------+
| 12346789  156789    1246789   | 123456789 12345678  1245678   | 236789    3456789   12346789  |
| 12356789  179       1245789   | 123689    12346789  12478     | 2356789   379       12345789  |
| 12369     12345679  12346789  | 12345689  12346     12345678  | 12346789  2345679   12347     |
+-------------------------------+-------------------------------+-------------------------------+
................1................................................................ 9.2, Double Forcing Chain: R2C9.5 on & off ==> R3C1.5 off
+-------------------------------+-------------------------------+-------------------------------+
| 35678     13456789  12346789  | 23456789  46789     12456789  | 2346789   3456789   4789      |
| 2356789   37        23457     | 2389      2346789   248       | 23689     1         2345789   |
| 12346789  1234567   1234678   | 12345689  123456789 12345678  | 23689     234569    2346789   |
+-------------------------------+-------------------------------+-------------------------------+
| 23456789  46789     12456789  | 1356789   13456789  145789    | 23456789  46789     12456789  |
| 23689     12346789  123456789 | 12356789  1379      12345789  | 12356789  2346789   12478     |
| 12345689  12346     123456789 | 123569    12345679  12347     | 12345689  2346      12345678  |
+-------------------------------+-------------------------------+-------------------------------+
| 12346789  156789    1246789   | 123456789 12345678  1245678   | 236789    3456789   12346789  |
| 12356789  179       1245789   | 123689    12346789  12478     | 2356789   379       12345789  |
| 12369     12345679  12346789  | 12345689  12346     12345678  | 12346789  2345679   12347     |
+-------------------------------+-------------------------------+-------------------------------+
................1................................................................ 9.2, Double Forcing Chain: R2C9.5 on & off ==> R1C1.5 off
+-------------------------------+-------------------------------+-------------------------------+
| 3678      13456789  12346789  | 23456789  46789     12456789  | 2346789   3456789   4789      |
| 2356789   37        23457     | 2389      2346789   248       | 23689     1         2345789   |
| 12346789  1234567   1234678   | 12345689  123456789 12345678  | 23689     234569    2346789   |
+-------------------------------+-------------------------------+-------------------------------+
| 23456789  46789     12456789  | 1356789   13456789  145789    | 23456789  46789     12456789  |
| 23689     12346789  123456789 | 12356789  1379      12345789  | 12356789  2346789   12478     |
| 12345689  12346     123456789 | 123569    12345679  12347     | 12345689  2346      12345678  |
+-------------------------------+-------------------------------+-------------------------------+
| 12346789  156789    1246789   | 123456789 12345678  1245678   | 236789    3456789   12346789  |
| 12356789  179       1245789   | 123689    12346789  12478     | 2356789   379       12345789  |
| 12369     12345679  12346789  | 12345689  12346     12345678  | 12346789  2345679   12347     |
+-------------------------------+-------------------------------+-------------------------------+

Source: The updated getHintsHint() code (in Solver.java) is below:
Hidden Text: Show
Code: Select all
    public void getHintsHint() {
        Grid backup = new Grid();
        grid.copyTo(backup);
        try {
            difficulty = Double.NEGATIVE_INFINITY;
            pearl = 0.0;
            diamond = 0.0;
            while (!isSolved()) {
                String s = "";

                int crd = 1;
                for (int i = 0; i < 81; i++) {
                    int n = grid.getCell(i % 9, i / 9).getPotentialValues().cardinality();
                    if ( n > crd ) { crd = n; }
                }
                if ( crd > 1 )
                {
                    for (int i=0; i<3; i++ ) {
                        s = "+";
                        for (int j=0; j<3; j++ ) {
                            for (int k=0; k<3; k++ ) { s += "-";
                                for (int l=0; l<crd; l++ ) { s += "-";
                                }
                            }
                            s += "-+";
                        }
                        System.out.println(s);
                        System.out.flush();

                        for (int j=0; j<3; j++ ) {
                            s = "|";
                            for (int k=0; k<3; k++ ) {
                                for (int l=0; l<3; l++ ) {
                                    s += " ";
                                    int cnt = 0;
                                    int c = ((((i*3)+j)*3)+k)*3+l;
                                    Cell cell = grid.getCell(c % 9, c / 9);
                                    int n = cell.getValue();
                                    if ( n != 0 ) {
                                        s += n;
                                        cnt += 1;
                                    }
                                    if ( n == 0 ) {
                                        for (int pv=1; pv<=9; pv++ ) {
                                            if ( cell.hasPotentialValue( pv) ) {
                                                s += pv;
                                                cnt += 1;
                                            }
                                        }
                                    }
                                    for (int pad=cnt; pad<crd; pad++ ) { s += " ";
                                    }
                                }
                                s += " |";
                            }
                            System.out.println(s);
                            System.out.flush();
                        }

                    }

                    s = "+";
                    for (int j=0; j<3; j++ ) {
                        for (int k=0; k<3; k++ ) { s += "-";
                            for (int l=0; l<crd; l++ ) { s += "-";
                            }
                        }
                        s += "-+";
                    }
                    System.out.println(s);
                    System.out.flush();
                }

                SingleHintAccumulator accu = new SingleHintAccumulator();
                try {
                    for (HintProducer producer : directHintProducers)
                        producer.getHints(grid, accu);
                    for (IndirectHintProducer producer : indirectHintProducers)
                        producer.getHints(grid, accu);
                    for (IndirectHintProducer producer : chainingHintProducers)
                        producer.getHints(grid, accu);
                    for (IndirectHintProducer producer : chainingHintProducers2)
                        producer.getHints(grid, accu);
                    for (IndirectHintProducer producer : advancedHintProducers)
                        producer.getHints(grid, accu);
                    for (IndirectHintProducer producer : experimentalHintProducers)
                        producer.getHints(grid, accu);
                } catch (InterruptedException willHappen) {}
                Hint hint = accu.getHint();
                if (hint == null) {
                    difficulty = 20.0;
                    break;
                }
                assert hint instanceof Rule;
                Rule rule = (Rule)hint;
                double ruleDiff = rule.getDifficulty();
                if (ruleDiff > difficulty)
                    difficulty = ruleDiff;
                hint.apply();

                s = "";
                for (int i = 0; i < 81; i++) {
                    int n = grid.getCellValue(i % 9, i / 9);
                    s += (n==0)?".":n;
                }
                s += " ";
                int w = (int)((ruleDiff + 0.05) * 10);
                int p = w % 10;
                w /= 10;
                s += w + "." + p;
                s += ", " + hint.toString();
                System.out.println(s);
                System.out.flush();

                if (pearl == 0.0) {
                    if (diamond == 0.0)
                        diamond = difficulty;
                    if (hint.getCell() != null) {
                        if (want == 'd' && difficulty > diamond) {
                            difficulty = 20.0;
                            break;
                        }
                        pearl = difficulty;
                    }
                }
                else if (want != 0 && difficulty > pearl) {
                    difficulty = 20.0;
                    break;
                }
            }
        } finally {
            backup.copyTo(grid);
        }
    }
Last edited by 1to9only on Mon Aug 05, 2019 8:22 am, edited 1 time in total.
1to9only
 
Posts: 4073
Joined: 04 April 2018

Re: Help With Sudoku Explainer

Postby dobrichev » Wed Jul 31, 2019 3:34 pm

Thank you!
I will run it for another 2 days to see if it will log more steps before giving up.

BTW is it possible to store the original source files on a public repository? The original project by Nicolas Juillerat disappeared, isn't it?
I've searched for clones and found some which possibly include already modified code.
On my machine I have some files but I am unsure whether they are clean and which version represent.

Cheers,
MD
dobrichev
2016 Supporter
 
Posts: 1830
Joined: 24 May 2010

Re: Help With Sudoku Explainer

Postby rjamil » Wed Jul 31, 2019 4:47 pm

Hi MD,

I have original source code of Sudoku Explainer by Nicolas Juillerat in my collection, containing 28-Dec-2007 zipped files of the same.

R. Jamil
Attachments
SudokuExplainer-src.zip
(190.96 KiB) Downloaded 163 times
rjamil
 
Posts: 671
Joined: 15 October 2014
Location: Karachi, Pakistan

Re: Help With Sudoku Explainer

Postby dobrichev » Wed Jul 31, 2019 8:09 pm

Thank you, rjamil. These source files appear to be authentic.

Now, the next part - does anybody want to create a public repository, say in github, for this project with appropriate credit to Nicolas?
Ideally, over time this project will accumulate links to the work of other contributors as well as code with improvements.

Personally I don't want to manage java project but if nobody else wants I can create it.
dobrichev
2016 Supporter
 
Posts: 1830
Joined: 24 May 2010

Re: Help With Sudoku Explainer

Postby 1to9only » Thu Aug 01, 2019 7:00 pm

I think that fixing the AE (AlignedExclusion) issue in SE for Aligned Pair (SE=6.2) and Triplet (SE=7.5) Exclusions will go some way to fix the sukaku solver.

The minimum number of clues in a vanilla sudoku puzzle is 17, the number of unsolved cells being 64 - which is exactly the number of bits in an integer. SE uses this feature: each bit in the integer is used to denote an unsolved cell - in Permutations.java, bits are set for permutations of unsolved cells that are being considered for exclusion.

The SE AlignedExclusion code does not work for sukakus that have more than 64 unsolved cells.

Modifying SE Permutations.java to use:
- a 128-bit integer (BigInteger) is a possibility, but I don't think bit manipulation is well suported.
- a BitSet is possible, but code changes are required.
- 2 64-bit integers, and more code changes are required.

I've no plans to try out any of the above.
1to9only
 
Posts: 4073
Joined: 04 April 2018

Re: Help With Sudoku Explainer

Postby dobrichev » Fri Aug 02, 2019 11:15 am

Hi 1to9only,

Below is a wrapper to Permutations. Could you try it?

I saw that from AlignedExclusion only Permutations.hasNext() followed by Permutations.nextBitNums() are called.
Replacing Permutations with Permutations128 in AlignedExclusion.java should work (after fixing the possible syntax errors and bugs in the attached Permutations128).

Hidden Text: Show
Code: Select all
public class Permutations128 {
   private final int countBitsLow;      //width of the low bits iterator, up to 64
   private final int countBitsHigh;   //width of the high bits iterator, possibly 0
   private final int maxCountOnesHigh;   //maximal bits iterated over high bits iterator, even when low bits iterator is left empty

   private int curCountOnesLow;      //start from maximal bits there, then move one bit at a time into curCountOnesHigh
   private int curCountOnesHigh;      //start from minimal bits there, then move one bit at a time from curCountOnesHigh

   private long nextHigh; //cached latest call to permHigh.next()

   private Permutations permLow; //lower 64-bit
   private Permutations permHigh; //higher 64-bit

   public Permutations128(int countOnes, int countBits) {
      if (countOnes < 0)
         throw new IllegalArgumentException("countOnes < 0");
      if (countBits < 0)
         throw new IllegalArgumentException("countBits < 0");
      if (countOnes > countBits)
         throw new IllegalArgumentException("countOnes > countBits");
      if (countBits > 128)
         throw new IllegalArgumentException("countBits > 128");

      curCountOnesLow = countOnes >= 64 ? 64 : countOnes;
      countBitsLow = countBits >= 64 ? 64 : countBits;
      countBitsHigh = countBits - countBitsLow;
      maxCountOnesHigh = countOnes >= countBitsHigh ? countBitsHigh : countOnes;
      curCountOnesHigh = countOnes - countBitsLow;
      permLow = new Permutations(curCountOnesLow, countBitsLow);
      if(curCountOnesHigh != 0) {
         permHigh = new Permutations(curCountOnesHigh, countBitsHigh);
      }
      nextHigh = 0;
   }
       public boolean hasNext() {
      if(curCountOnesHigh == 0) {
         //act as a simple wrapper to permLow
         return permLow.hasNext();
      }
      if(curCountOnesLow == 0) {
         //act as a simple wrapper to permHigh
         return permHigh.hasNext();
      }
      if(permLow.hasNext()) return true;
      //we need to reduild permLow and either advance or rebuild permHigh
      if(permHigh.hasNext()) {
         //only rebuild permLow
         permLow = new Permutations(curCountOnesLow, countBitsLow);
         permLow.hasNext(); //init permLow, it returns false for empty set but we need one successfull next() iteration even then
         nextHigh = permHigh.next(); //get into cache, then advance
         return true;
      }
      else {
         //we need to rebuild both permLow and permHigh
         if(curCountOnesHigh == maxCountOnesHigh) return false; //we are done
         //move one bit from the lower to the upper part and restart
         curCountOnesHigh++;
         curCountOnesLow--;
         if(curCountOnesLow != 0) {
            permLow = new Permutations(curCountOnesLow, countBitsLow);
            permLow.hasNext(); //init permLow, it returns false for empty set but we need one successfull next() iteration even then
         }
         permHigh = new Permutations(curCountOnesHigh, countBitsHigh);
         permHigh.hasNext(); //init permHigh, it returns false for empty set but we need one successfull next() iteration even then
         nextHigh = permHigh.next(); //get into cache, then advance
      }
      return true;
   }
   public int[] nextBitNums() {
      if(curCountOnesHigh == 0) {
         //act as a simple wrapper to permLow
         return permLow.nextBitNums();
      }
      int[] result = new int[countOnes];
      int dst = 0;
      if(curCountOnesLow == 0) {
         //add 64 to indexes
         long mask = permHigh.next();
         for (int src = 0; src < countBitsHigh; src++) {
            if ((mask & (1L << src)) != 0) // Bit number 'src' is set
               result[dst++] = src + 64;
         }
         return result;
      }
      //merge both iterators
      long mask = permLow.next(); //get then advance
      for (int src = 0; src < countBitsLow; src++) {
         if ((mask & (1L << src)) != 0) // Bit number 'src' is set
            result[dst++] = src;
      }
      mask = nextHigh; //get only
      for (int src = 0; src < countBitsHigh; src++) {
         if ((mask & (1L << src)) != 0) // Bit number 'src' is set
            result[dst++] = src + 64;
      }
      return result;
   }
}


Aren't AlignedExclusion techniques covered by the complicated chains or there are special filters in chains techniques that expect AlignedExclusion was previously applied?

If AlignedExclusion is covered by the more complex techniques, then enabling it wouldn't resolve the ER=20.0 problem IMO.
dobrichev
2016 Supporter
 
Posts: 1830
Joined: 24 May 2010

Re: Help With Sudoku Explainer

Postby 1to9only » Fri Aug 02, 2019 4:37 pm

I've written some test code for Permutations.java:
Hidden Text: Show
Code: Select all
      String s = "";
      int count = 0;
      Permutations cellSetPerm2 = new Permutations( 2, 9);
      while ( cellSetPerm2.hasNext() ) {
         int[] indexes = cellSetPerm2.nextBitNums();
         s = "";
         if ( count < 10 ) {
            s += " ";
         }
         s += count + ": " + indexes[0] + ", " + indexes[1];
         System.out.println( s);
         count++;
      }

Output:
Hidden Text: Show
Code: Select all
 0: 0, 1
 1: 0, 2
 2: 1, 2
 3: 0, 3
 4: 1, 3
 5: 2, 3
 6: 0, 4
 7: 1, 4
 8: 2, 4
 9: 3, 4
10: 0, 5
11: 1, 5
12: 2, 5
13: 3, 5
14: 4, 5
15: 0, 6
16: 1, 6
17: 2, 6
18: 3, 6
19: 4, 6
20: 5, 6
21: 0, 7
22: 1, 7
23: 2, 7
24: 3, 7
25: 4, 7
26: 5, 7
27: 6, 7
28: 0, 8
29: 1, 8
30: 2, 8
31: 3, 8
32: 4, 8
33: 5, 8
34: 6, 8
35: 7, 8

The same test code for Permutations128.java:
Hidden Text: Show
Code: Select all
      String s = "";
      int count = 0;
      Permutations128 cellSetPerm128 = new Permutations128( 2, 9);
      while ( cellSetPerm128.hasNext() ) {
         int[] indexes = cellSetPerm128.nextBitNums();
         s = "";
         if ( count < 10 ) {
            s += " ";
         }
         s += count + ": " + indexes[0] + ", " + indexes[1];
         System.out.println( s);
         count++;
      }

Output: as for Permutations.java, and then an exception:
Hidden Text: Show
Code: Select all
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
        at diuf.sudoku.Tester.main(Unknown Source)

Needs some debugging (I'll find some time!) - looks to be in hasNext().

In SE, for APE/ATE CountOnes is always 2. For ATE, AlignedExclusion.java has this comment:
Hidden Text: Show
Code: Select all
        /*
         * To iterate over 'n' cells (n > 2), we first iterate among
         * two cells. Then we retain only the other cells that are
         * visible by at least one of these two cells (the twinArea), and we
         * continue the iteration on these remaining cells.
         */
1to9only
 
Posts: 4073
Joined: 04 April 2018

Re: Help With Sudoku Explainer

Postby dobrichev » Fri Aug 02, 2019 6:10 pm

in Permutations128 the line in nextBitNums()
Code: Select all
      int[] result = new int[countOnes];

should be
Code: Select all
      int[] result = new int[curCountOnesLow  + countBitsHigh];

(How it compiles? Should everywhere this.xxx be used for safety?)

Your test demonstrated that even for < 64 bits the emulator doesn't work.

Good next test cases include
Code: Select all
Permutations128 cellSetPerm128 = new Permutations128( 0, 9); // <=== the first call to hasNext() should return false
Permutations128 cellSetPerm128 = new Permutations128( 1, 90); // <=== will test only lower and only higher iterators
Permutations128 cellSetPerm128 = new Permutations128( 2, 90); // <=== will test merging the lower and higher iterators
dobrichev
2016 Supporter
 
Posts: 1830
Joined: 24 May 2010

PreviousNext

Return to Interactive games