Patterns Game benchmark file

Everything about Sudoku that doesn't fit in one of the other sections

Re: Patterns Game benchmark file

Postby 1to9only » Mon Apr 27, 2020 11:38 am

champagne wrote:As far as I remember, only one very old puzzle was published with a rating not in line with the referee current rating.

I found this in game 0017 entry 138:
009000600000301000800050002050708030008000700070503040200030009000407000006000100 # 138 4.0/4.0/3.2 - m_b_metcalf
SE rates this ED=7.2/7.2/3.2, I've corrected this in my results file.
.
User avatar
1to9only
 
Posts: 4177
Joined: 04 April 2018

Re: Patterns Game benchmark file

Postby rjamil » Mon Apr 27, 2020 1:36 pm

Hi 1to9only and Mike Metcalf,

1to9only wrote:Add '&view=print' to the url, e.g. viewtopic.php?f=8&t=6291&view=print - use copy&paste to save the contents to a text file. Repeat for 26 pages.

BTW, I see no significant difference in processing the page by either adding '&view=print' or not in url address.

Pick out the line 'game NNNN YYYY-MM-DD+HH:MM:SS-0000 ...' for the game number.
Convert empty cells '0' to dots '.'.
Include the game number in the output line, e.g.
..1...2...2...4.1.6...8...4..86.2..5....1....4..3.79..5...9...7.1.5...3...3...1.. # 0382 1 1.5/1.2/1.2 - champagne

I like it and will implement the same accordingly.

Here is a quick fix for '0' to '.': [Modified as on 20200427]
Code: Select all
#include <stdio.h>

int main (void)
{
  int i;

  char a[1024],
       g[4];

  FILE *f = fopen ("PGResult.txt", "r");

  if (f == NULL)
    printf ("Error: Unable to open PGResult.txt file for read !!\n");
  else
    while (fgets (a, 1024, f) != NULL)
    {
      if (a[0] == 'g' && a[1] == 'a' && a[2] == 'm' && a[3] == 'e')
      {
        g[0] = a[5];
        g[1] = a[6];
        g[2] = a[7];
        g[3] = a[8];
      }
      for (i = 0; i < 81; ++i)
        if (a[i] < '0' || a[i] > '9')
          break;
        else if (a[i] == '0')
          a[i] = '.';
      if (i > 80)
        printf ("%s ", a);
    }
  if (fclose (f) == EOF)
    printf ("Error: Unable to close PGResult.txt file !!");
}


For games 0001-0381 inclusive, I have 39,128 entries. This includes updated games 12-13 and all more entries.

Will you please explain what do you mean by and how "includes updated games 12-13 and all more entries"? [Answered]
I got 39,189 puzzles. I think my entries included 44 posted pearls from game 12; and 17 posted pearls from game 13; i.e., total 61 more puzzles.

m_b_metcalf wrote:If I were to start again, I would investigate web scraping.

I prefer Human copy-and-paste method.

R. Jamil
Last edited by rjamil on Mon Apr 27, 2020 5:02 pm, edited 1 time in total.
rjamil
 
Posts: 781
Joined: 15 October 2014
Location: Karachi, Pakistan

Re: Patterns Game benchmark file

Postby 1to9only » Mon Apr 27, 2020 2:36 pm

rjamil wrote:
1to9only wrote:Add '&view=print' to the url, e.g. viewtopic.php?f=8&t=6291&view=print - use copy&paste to save the contents to a text file. Repeat for 26 pages.

BTW, I see no significant difference in processing the page by either adding '&view=print' or not in url address.

Yes, the pages saved are essentially the same, there are minor forum text differences which has no effects on the puzzles.

For games 0001-0381 inclusive, I have 39,128 entries. This includes updated games 12-13 and all more entries.

Will you please explain what do you mean by and how "includes updated games 12-13 and all more entries"?

The Patterns Game Results (first) page does not have the final results for game 12-13. For these I refer back to what g.r.emlin posted in the Patterns Game.
game 0012 results: http://forum.enjoysudoku.com/post51345.html#p51345
game 0013 results: http://forum.enjoysudoku.com/post51550.html#p51550

More entries are demoted by a '+' tag on the puzzle line in the results file, e.g.
Code: Select all
..1...2...2...4.1.6...8...4..86.2..5....1....4..3.79..5...9...7.1.5...3...3...1.. # 0382 1 1.5/1.2/1.2 - champagne
                                                                                                       |
                                                                                                       tag                     

A '0' tag means the rating has not been played before in previous games, '1' for played once before and '2' for played twice before.
.
User avatar
1to9only
 
Posts: 4177
Joined: 04 April 2018

Re: Patterns Game benchmark file

Postby Hajime » Mon Apr 27, 2020 3:36 pm

champagne wrote:I loaded Mike's file in my site.

It can be down loaded from games_sample

I solved 26855 Sudoku's with an average solution time of 4.852 ms each (elapsed 2 minutes 10.29 seconds).
Using SinglesOnly and BruteForce/Backtrack, so not the difficult all-existing-methods options included.
Reading the thread "3.77us Solver(2.8G CPU, TestCase:17Sodoku) " .... :( . That is a 1000 times faster :o
User avatar
Hajime
 
Posts: 1385
Joined: 20 April 2018
Location: Fryslân

Re: Patterns Game benchmark file

Postby dobrichev » Mon Apr 27, 2020 4:52 pm

Once I used the PHP code below to scan Patterns game results and store them in XML for later XPATH processing.
Hidden Text: Show
Code: Select all
<?php
//load patterns game results from forum.enjoysudoku.com and store submissions into a xml file for later processing
$targetDoc = new DOMDocument ();
$targetDoc->formatOutput = true;
$node = $targetDoc->createElement ( "patternGames" );
$targetRoot = $targetDoc->appendChild ( $node );
$games = array ();

$url = 'http://forum.enjoysudoku.com/patterns-game-results-t6291-15.html'; // first game of interest

do {
   $response = file_get_contents ( $url );
   // print_r($response);
   // return;
   
   // set_error_handler(function($number, $error){
   // if (preg_match('/^DOMDocument::loadXML\(\): (.+)$/', $error, $m) === 1) {
   // throw new Exception($m[1]);
   // }
   // });
   $doc = DOMDocument::loadHTML ( $response );
   // $doc->loadXML($response);
   // restore_error_handler();
   
   $xpath = new DOMXPath ( $doc );
   // $xpath->registerNameSpace('html', $doc->documentElement->getAttribute(xmlns)); //if using loadXML node names must be prefixed, say by 'html'
   
   $query = "//div[@class='content']";
   $entries = $xpath->query ( $query );
   foreach ( $entries as $entry ) {
      sscanf ( $entry->firstChild->textContent, '::: game %s ', $gameNumber );
      if (in_array ( $gameNumber, $games ))
         continue; // skip duplicates when traversing pages
      array_push ( $games, $gameNumber );
      $gameNode = $targetDoc->createElement ( 'game' );
      $domAttribute = $targetDoc->createAttribute ( 'gameNumber' );
      $domAttribute->value = "$gameNumber";
      $gameNode->appendChild ( $domAttribute );
      $query = "descendant::code[position()=last()]/text()";
      $submissionsSRC = $xpath->query ( $query, $entry );
      // print_r($submissionsSRC);
      $lastSubmission = false;
      $rating = false;
      for($i = 1; $i < $submissionsSRC->length; $i ++) { // skip index 0
         $submission = str_replace ( "\xc2\xa0", ' ', $submissionsSRC->item ( $i )->textContent ); // strip '&nbsp;'
         $fields = preg_split ( '/[\s]+/', $submission );
         $submissionNode = $targetDoc->createElement ( 'submission' );
         // {
         // $domAttribute = $targetDoc->createAttribute ( 'raw-debug' );
         // $domAttribute->value = "$submission";
         // $submissionNode->appendChild ( $domAttribute );
         // }
         {
            $domAttribute = $targetDoc->createAttribute ( 'givens' );
            $domAttribute->value = str_replace ( '0', '.', $fields [0] );
            $submissionNode->appendChild ( $domAttribute );
         }
         {
            $domAttribute = $targetDoc->createAttribute ( 'ordinal' );
            $domAttribute->value = "$fields[2]";
            $submissionNode->appendChild ( $domAttribute );
         }
         {
            $rating = explode ( '/', $fields [3] );
            {
               $domAttribute = $targetDoc->createAttribute ( 'er' );
               $domAttribute->value = $rating [0];
               $submissionNode->appendChild ( $domAttribute );
            }
            {
               $domAttribute = $targetDoc->createAttribute ( 'ep' );
               $domAttribute->value = $rating [1];
               $submissionNode->appendChild ( $domAttribute );
            }
            {
               $domAttribute = $targetDoc->createAttribute ( 'ed' );
               $domAttribute->value = $rating [2];
               $submissionNode->appendChild ( $domAttribute );
            }
         }
         $isMore = false;
         switch ($fields [4]) {
            case '-' :
               break;
            case '0' :
            case '1' :
            case '2' :
               $domAttribute = $targetDoc->createAttribute ( 'rare' );
               $domAttribute->value = "$fields[4]";
               $submissionNode->appendChild ( $domAttribute );
               break;
            case '+' :
               $domAttribute = $targetDoc->createAttribute ( 'more' );
               $domAttribute->value = "yes";
               $submissionNode->appendChild ( $domAttribute );
               $isMore = true;
               break;
            default :
               break;
         }
         if ($lastSubmission) {
            if ($lastSubmission->attributes->getNamedItem ( 'er' )->nodeValue == $rating [0]) {
               $domAttribute = $targetDoc->createAttribute ( 'trumped' );
               $domAttribute->value = $isMore ? 'more' : 'regular';
               $lastSubmission->appendChild ( $domAttribute );
            }
         }
         {
            $domAttribute = $targetDoc->createAttribute ( 'submitter' );
            $domAttribute->value = "$fields[5]";
            $submissionNode->appendChild ( $domAttribute );
         }
         $gameNode->appendChild ( $submissionNode );
         $lastSubmission = $submissionNode;
      }
      $targetRoot->appendChild ( $gameNode );
   }
   // last page?
   $url = false;
   $query = "//fieldset[@class='display-options']/a[@class='right-box right' and text() = 'Next']/@href";
   $entries = $xpath->query ( $query );
   if ($entries) {
      $url = $entries [0]->nodeValue;
   }
} while ( $url );

echo $targetDoc->saveXML ();
?>

Result looks like
Code: Select all
<?xml version="1.0"?>
<patternGames>
  <game gameNumber="0015">
    <submission givens="..3...9...26...78.19.....32...2.6......893......4.5...31.....94.87...25...9...3.." ordinal="11" er="2.0" ep="2.0" ed="2.0" submitter="tarek"/>
    <submission givens="..4...9...37...54.19.....38...1.3......589......2.4...46.....89.12...36...5...7.." ordinal="1" er="2.3" ep="1.2" ed="1.2" submitter="m_b_metcalf" trumped="regular"/>
...
  </game>
  <game gameNumber="0379">
...
    <submission givens="..1..4....3.5..6..8...6..7..4......5..9...8..7......2..5..8...4..2..7.9....6..3.." ordinal="51" er="7.7" ep="7.5" ed="3.4" more="yes" submitter="JPF"/>
    <submission givens="..1..2....3.1..4..5...6..7..6......8..4...2..9......1..8..5...6..2..1.9....4..7.." ordinal="43" er="7.8" ep="7.2" ed="7.2" rare="2" submitter="m_b_metcalf" trumped="more"/>
    <submission givens="..1..3....6.4..2..9...2..7..4......2..6...3..7......1..3..5...4..9..7.5....1..6.." ordinal="50" er="7.8" ep="7.8" ed="6.7" more="yes" submitter="JPF"/>
    <submission givens="..1..2....3.1..4..5...6..7..8......9..4...2..7......1..5..7...8..2..1.5....4..6.." ordinal="41" er="7.9" ep="7.2" ed="7.2" submitter="m_b_metcalf" trumped="regular"/>
...
  </game>
</patternGames>
dobrichev
2016 Supporter
 
Posts: 1863
Joined: 24 May 2010

Re: Patterns Game benchmark file

Postby rjamil » Mon Apr 27, 2020 5:15 pm

Hi Hajime,

Hajime wrote:I solved 26855 Sudoku's with an average solution time of 4.852 ms each (elapsed 2 minutes 10.29 seconds).
Using SinglesOnly and BruteForce/Backtrack, so not the difficult all-existing-methods options included.
Reading the thread "3.77us Solver(2.8G CPU, TestCase:17Sodoku) " .... :( . That is a 1000 times faster :o

My singleton and BruteForce/Backtrack iterative RJSudoku.c solver solved 26855 Sudokus with an average solution time of 1.596 ms per puzzle (elapsed 42.86 sec).

P.S. 1to9only: Please check my above mentioned updated post.

R. Jamil
rjamil
 
Posts: 781
Joined: 15 October 2014
Location: Karachi, Pakistan

Re: Patterns Game benchmark file

Postby m_b_metcalf » Mon Apr 27, 2020 6:51 pm

rjamil wrote:
Hajime wrote:I solved 26855 Sudoku's with an average solution time of 4.852 ms each (elapsed 2 minutes 10.29 seconds).
Using SinglesOnly and BruteForce/Backtrack, so not the difficult all-existing-methods options included.
Reading the thread "3.77us Solver(2.8G CPU, TestCase:17Sodoku) " .... :( . That is a 1000 times faster :o

My singleton and BruteForce/Backtrack iterative RJSudoku.c solver solved 26855 Sudokus with an average solution time of 1.596 ms per puzzle (elapsed 42.86 sec).]

Two points about these timing comparisons:

1) You should state whether uniqueness is assumed (code stops at first found solution rather checking there are no more). My code is 60% slower when not assuming uniqueness.

2) About 80% of the 17-clue puzzles can be solved using singles only, so it's not a very revealing test.

Regards,

Mike
User avatar
m_b_metcalf
2017 Supporter
 
Posts: 13637
Joined: 15 May 2006
Location: Berlin

Re: Patterns Game benchmark file

Postby rjamil » Tue Apr 28, 2020 2:49 am

Hi Mike Metcalf,

m_b_metcalf wrote:1) You should state whether uniqueness is assumed (code stops at first found solution rather checking there are no more). My code is 60% slower when not assuming uniqueness.

Yes. Uniqueness is assumed (code stops at first found solution rather checking there are no more).

2) About 80% of the 17-clue puzzles can be solved using singles only, so it's not a very revealing test.

I have a question regarding puzzles that can be solved using singles only (or with the help of whatever non-assumptive moves implemented in solver). If puzzle solved without backtracking, how do one know that the puzzle has a unique solution?

However, I have strong feeling that, only those puzzles that required trial-and-error, need to be check for multi-solution. (In 17-clue puzzles, need around 20% or less to check uniqueness if solved with singleton moves and/or some non-assumptive moves.)

R. Jamil
rjamil
 
Posts: 781
Joined: 15 October 2014
Location: Karachi, Pakistan

Re: Patterns Game benchmark file

Postby m_b_metcalf » Tue Apr 28, 2020 7:05 am

rjamil wrote:I have a question regarding puzzles that can be solved using singles only (or with the help of whatever non-assumptive moves implemented in solver). If puzzle solved without backtracking, how do one know that the puzzle has a unique solution?

Basically because a puzzle can't be fully solved by logic if it has multiple solutions. In this case, one (or more) unavoidable sets are not covered by a clue. A simple example is the 77-clue puzzle
Code: Select all
 2 8 3 5 9 6 1 7 4
 4 6 . 7 1 3 8 2 .
 7 1 . 8 4 2 6 3 .
 1 2 7 9 6 5 3 4 8
 3 9 4 2 8 1 7 5 6
 8 5 6 4 3 7 9 1 2
 9 3 1 6 5 4 2 8 7
 5 7 8 1 2 9 4 6 3
 6 4 2 3 7 8 5 9 1

which, by inspection, has two solutions, both of which only a backtracking solver will find.

HTH

Mike
User avatar
m_b_metcalf
2017 Supporter
 
Posts: 13637
Joined: 15 May 2006
Location: Berlin

Re: Patterns Game benchmark file

Postby rjamil » Tue Apr 28, 2020 12:46 pm

Hi Mike Metcalf,

m_b_metcalf wrote:Basically because a puzzle can't be fully solved by logic if it has multiple solutions. In this case, one (or more) unavoidable sets are not covered by a clue. A simple example is the 77-clue puzzle
Code: Select all
 2 8 3 5 9 6 1 7 4
 4 6 . 7 1 3 8 2 .
 7 1 . 8 4 2 6 3 .
 1 2 7 9 6 5 3 4 8
 3 9 4 2 8 1 7 5 6
 8 5 6 4 3 7 9 1 2
 9 3 1 6 5 4 2 8 7
 5 7 8 1 2 9 4 6 3
 6 4 2 3 7 8 5 9 1

which, by inspection, has two solutions, both of which only a backtracking solver will find.

True. And my solver not only reports the current pm state as BUG+0, but solve with trial-and-error. (Means, no pre-programmed logical moves applied at current pm state.)

As a counter example, by changing just two cells of the said puzzle, i.e., r2c2 from "6" to "."; and r2c3 from "." to "5", it solves with 4 Naked Single moves. In that case, how brute force solver confirm that the puzzle has a unique solution?

R. Jamil
rjamil
 
Posts: 781
Joined: 15 October 2014
Location: Karachi, Pakistan

Re: Patterns Game benchmark file

Postby m_b_metcalf » Tue Apr 28, 2020 1:41 pm

rjamil wrote:As a counter example, by changing just two cells of the said puzzle, i.e., r2c2 from "6" to "."; and r2c3 from "." to "5", it solves with 4 Naked Single moves. In that case, how brute force solver confirm that the puzzle has a unique solution?

Adding the clue at r2c3 covers the UA4 in my example, so it now has a unique solution. If you really want to confirm that with a brute-force solver, you should skip the singles step and feed the puzzle directly into that solver, asking it to count the number of solutions.

HTH

Mike
User avatar
m_b_metcalf
2017 Supporter
 
Posts: 13637
Joined: 15 May 2006
Location: Berlin

4353 unique patterns game puzzles

Postby 1to9only » Tue May 26, 2020 12:48 pm

File contains 4353 unique ER/EP/ED puzzles submitted in the patterns games 1 to 385 inclusive of :::more::: entries.
ATTACHMENT
pg-0001-0385-uniques.zip (136,930 bytes)
Last edited by 1to9only on Wed Feb 24, 2021 9:50 pm, edited 1 time in total.
User avatar
1to9only
 
Posts: 4177
Joined: 04 April 2018

Patterns Game 384 - 10848 unique puzzles

Postby 1to9only » Thu May 28, 2020 5:43 pm

In Patterns Game 384, I generated 10848 unique ER/EP/ED puzzles for this pattern.
I only rated a selected number of puzzles, so I could have missed a few ratings!
File contains lots of ratings never submitted in the patterns game!
ATTACHMENT
pg-0384.uniques.zip (211,605 bytes)
User avatar
1to9only
 
Posts: 4177
Joined: 04 April 2018

Previous

Return to General