Team project: C or C++ Explainer-like rating program

Programs which generate, solve, and analyze Sudoku puzzles

Re: Team project: C or C++ Explainer-like rating program

Postby ronk » Tue Sep 28, 2010 12:33 pm

Paul, where in Explainer's source is the Java equivalent to C's typedef for "Grid" :?:
ronk
2012 Supporter
 
Posts: 4764
Joined: 02 November 2005
Location: Southeastern USA

Re: Team project: C or C++ Explainer-like rating program

Postby JasonLion » Tue Sep 28, 2010 12:54 pm

Grid.java (and Cell.java), both in the sudoku folder. Most of the source files are in folders below that, but the Grid, Region (house), and Cell code is at the "top level" of the source code tree.

Grid is a class that contains 81 cell objects and the Row, Column, and Block arrays (each of which contains 9 objects derived from Region (what SE calls a house)). Java classes are much like C++ objects. The most obvious difference from C/C++ is that Java doesn't have .h files. Everything is in a single .java source file, instead of being split into declarations in the .h file and implementation in the .c (or .cc) file.
User avatar
JasonLion
2017 Supporter
 
Posts: 642
Joined: 25 October 2007
Location: Silver Spring, MD, USA

Re: Team project: C or C++ Explainer-like rating program

Postby champagne » Tue Sep 28, 2010 1:31 pm

JasonLion wrote:The most obvious difference from C/C++ is that Java doesn't have .h files. Everything is in a single .java source file, instead of being split into declarations in the .h file and implementation in the .c (or .cc) file.



In fact, you can put methods everywhere, including in the .h files.

Normally you should not if you want to use precompiled headers.
The true and only constraint is that you can not use a name before it has been defined.
This is normally enough to be forced to split files in .h and .cpp

champagne
champagne
2017 Supporter
 
Posts: 7466
Joined: 02 August 2007
Location: France Brittany

Re: Team project: C or C++ Explainer-like rating program

Postby Red Ed » Tue Sep 28, 2010 5:21 pm

If this really is going to be a team project then the team will need a place to share code and results.

How about using Sudopedia?
Red Ed
 
Posts: 633
Joined: 06 June 2005

Re: Team project: C or C++ Explainer-like rating program

Postby ronk » Tue Sep 28, 2010 5:51 pm

Red Ed wrote:If this really is going to be a team project then the team will need a place to share code and results.

How about using Sudopedia?

What can one do on sudopedia that can't be done here?
ronk
2012 Supporter
 
Posts: 4764
Joined: 02 November 2005
Location: Southeastern USA

Re: Team project: C or C++ Explainer-like rating program

Postby Red Ed » Tue Sep 28, 2010 8:50 pm

ronk wrote:What can one do on sudopedia that can't be done here?
We can all (not just "one") maintain a link-o-rama without having to rely upon one person keeping a head post up to date.

In fact, that's what I recommend we only use Sudopedia for. Discussion should remain here on the forum.
Red Ed
 
Posts: 633
Joined: 06 June 2005

Re: Team project: C or C++ Explainer-like rating program

Postby champagne » Wed Sep 29, 2010 7:27 am

Command line

Some thoughts about the command line.

Basically, the command line can be empty for the standard process if we have a default value for the input file and the output file.

In my tests, I’ll use respectively “puz.txt” and “rat.txt” in the current directory.


In the current” serate” process, if I am right, we have 2 additional options:

. look for ED only (diamonds)
. look for EP only (pearl)

My experience suggests more options to give some flexibility in the pattern game (I do it for the time being using my solver)

. look for ER lower than …
. look for ED higher than
. look for “differed ED” higher than
(this is something I do to catch potential high puzzles with low ED. I look for the “pseudo ED” during 2 or more cycles, to keep puzzles having high ER and low ED)
. look for a specific range of “ED”

These are examples of options giving some flexibility in the rating at a reasonable price.

The game is open, knowing that each one will have the opportunity to customize the command line restarting from the sources.


Compiling platform

This is another topic.
If the code is written in C++,I suggest to use the free Microsoft Visual C++ platform.

champagne
champagne
2017 Supporter
 
Posts: 7466
Joined: 02 August 2007
Location: France Brittany

Re: Team project: C or C++ Explainer-like rating program

Postby ronk » Wed Sep 29, 2010 11:10 am

champagne wrote:Command line

Some thoughts about the command line.

Basically, the command line can be empty for the standard process if we have a default value for the input file and the output file.

In my tests, I’ll use respectively “puz.txt” and “rat.txt” in the current directory.


In the current” serate” process, if I am right, we have 2 additional options:

. look for ED only (diamonds)
. look for EP only (pearl)

Assuming you are writing a skeleton to which others would add techniques to emulate Explainer, I think gsf's serate shows the way.

serate wrote:
Code: Select all
OPTIONS
  -d, --diamond
      Terminate rating if the puzzle is not a diamond.
  -f, --format=FORMAT
      Format the output for each input puzzle according to FORMAT.  Format
      conversion are %CHARACTER; all other characters are output unchanged.
      The default format is %r/%p/%d.  The format conversions are:
        %d  The diamond rating.  This is the highest ER of the methods leading
            to the first candidate elimination.
        %e  The elapsed time to rate the puzzle.
        %g  The puzzle grid in 81-character [0-9] form.
        %n  The input puzzle ordinal, counting from 1.
        %p  The pearl rating.  This is the highest ER of the methods leading
            to the first cell placement.
        %r  The puzzle rating.  This is the highest ER of the methods leading
            to the puzzle solution.
        %%  The % character.
  -h, --html
      List detailed info in html.
  -i, --input=FILE
      Read 81-character puzzle strings, one per line, from FILE.  By default
      operands are treated as 81-character puzzle strings.  If no operands are
      specified then the standard input is read.
  -m, --man
      List detailed info in displayed man page form.
  -o, --output=FILE
      Write output to FILE instead of the standard output.
  -p, --pearl
      Terminate rating if the puzzle is not a pearl.
  -V, --version
      Print the Sudoku Explainer (serate) version and exit.


champagne wrote:My experience suggests more options to give some flexibility in the pattern game (I do it for the time being using my solver)

. look for ER lower than …
. look for ED higher than
. look for “differed ED” higher than
(this is something I do to catch potential high puzzles with low ED. I look for the “pseudo ED” during 2 or more cycles, to keep puzzles having high ER and low ED)
. look for a specific range of “ED”

These are examples of options giving some flexibility in the rating at a reasonable price.

The game is open, knowing that each one will have the opportunity to customize the command line restarting from the sources.

To the above, ala gsf's sudoku.exe, I suggest adding a "-e" option for such filtering ... with rating labels %ER, %EP and %ED or similar. The -e option could then contain a C-like expression, for example ... -e"%ER>=4.0&&%ER<7.1"
ronk
2012 Supporter
 
Posts: 4764
Joined: 02 November 2005
Location: Southeastern USA

Re: Team project: C or C++ Explainer-like rating program

Postby champagne » Wed Sep 29, 2010 12:46 pm

ronk wrote:Assuming you are writing a skeleton


What I am doing is a kind of “restart form scratch” using some code of my solver.

I am using the on-line version of SE to catch the rating rules. I have no need at that point to dig in existing code;

If it works, I should be within 2 or 3 weeks in a position to match the first part of the rating (say in the range ED=1 to ED=9);

For higher ratings, I don’t know if I have the right tools in my solver. I have first to understand what SE is doing.

BTW I am meantime rating my database of hardest with SE, so I’ll have a sample file covering all the field for the tests.



ronk wrote:I think gsf's serate shows the way.


No reason to change the command for existing options.
However, some of the options in the existing lisr don’t seem to be very usefull.


ronk wrote:To the above, ala gsf's sudoku.exe, I suggest adding a "-e" option for such filtering ... with rating labels %ER, %EP and %ED or similar. The -e option could then contain a C-like expression, for example ... -e"%ER>=4.0&&%ER<7.1"


Nothing to object in principle, except that filtering on ER has no meaning (the puzzle is solved).To be efficient, filters have to work on ED or a “quasi ED” ;

champagne
champagne
2017 Supporter
 
Posts: 7466
Joined: 02 August 2007
Location: France Brittany

Re: Team project: C or C++ Explainer-like rating program

Postby champagne » Wed Sep 29, 2010 12:49 pm

champagne wrote:
ronk wrote:Assuming you are writing a skeleton


What I am doing is a kind of “restart form scratch” using some code of my solver.

I am using the on-line version of SE to catch the rating rules. I have no need at that point to dig in existing code;

If it works, I should be within 2 or 3 weeks in a position to match the first part of the rating (say in the range ED=1 to ED=9);

For higher ratings, I don’t know if I have the right tools in my solver. I have first to understand what SE is doing.

BTW I am meantime rating my database of hardest with SE, so I’ll have a sample file covering all the field for the tests.



ronk wrote:I think gsf's serate shows the way.


No reason to change the command for existing options.
However, some of the options in the existing lisr don’t seem to be very usefull.


ronk wrote:To the above, ala gsf's sudoku.exe, I suggest adding a "-e" option for such filtering ... with rating labels %ER, %EP and %ED or similar. The -e option could then contain a C-like expression, for example ... -e"%ER>=4.0&&%ER<7.1"


Nothing to object in principle, except that filtering on ER has no meaning (the puzzle is solved).To be efficient, filters have to work on ED or a “quasi ED” ;

champagne



EDIT: I am interested in getting the code used by gsf to parse the command line (it would save time)
champagne
2017 Supporter
 
Posts: 7466
Joined: 02 August 2007
Location: France Brittany

Re: Team project: C or C++ Explainer-like rating program

Postby ronk » Wed Sep 29, 2010 5:54 pm

champagne wrote:I am interested in getting the code used by gsf to parse the command line (it would save time)

It's in serate.java in the serate tarball published here.

P.S. Why are you yelling?
ronk
2012 Supporter
 
Posts: 4764
Joined: 02 November 2005
Location: Southeastern USA

Re: Team project: C or C++ Explainer-like rating program

Postby champagne » Wed Sep 29, 2010 8:52 pm

ronk wrote:
champagne wrote:I am interested in getting the code used by gsf to parse the command line (it would save time)

It's in serate.java in the serate tarball published here.

P.S. Why are you yelling?



thanks for help, but this is a .tgz file and I don't know how to use it.

champagne

ps: I put my edit in large/red to be sure anybody in a position to help me would read it.

edit: I found informations to process .tgz files.
I had no program to handle compressed files, now I have one !!!
champagne
2017 Supporter
 
Posts: 7466
Joined: 02 August 2007
Location: France Brittany

Re: Team project: C or C++ Explainer-like rating program

Postby AR4793 » Sun Oct 03, 2010 2:17 am

Ok, I'll jump into the discussion and get my feet moist.

To start with couldn't you add an option "File/Run File" to the GUI version to just read in lines one at a time and calculate he rating and print the puzzle line concatenated with the rating at the end of the line in another file? That would for once all preserve this version of Sudoku Explainer. Who care if this version is fast, just so it runs a file and gives the same rating as the current GUI version.

It would seem that the next step would be to separate parts of the program. Using the Model-View-Controller paradigm from object oriented programming, the model is where the grunt work is done. If you parse a command line or have a full GUI, that is the View part. I'm not sure what else you want, but it would be easy to think of the model as a subroutine. At the most basic level you pass in a 81 charter string and get a rating back. If you get the model working faster, the Java GUI could call the compiled subroutine too. You'd need a contact (specifications) as to how the view, model, and controller would interact.

Frankly, I'd like a GUI too for all the switch options. Show me what the completed command line looks like, then spawn a separate program to run what was selected in the background.

What would be a confusing mess is if the GUI version of Sudoku Explainer and the command line parser version started releasing different versions.

All of this would make a somewhat larger project, but if the GUI version got updated with new techniques too that would be a big plus.

- - -

As a side note is there a way to use something like CSV on a website to control the code versions? Without some sort of coordinated version control, collaboration is very difficult.

- - - -


Regards,
Herb
AR4793
 
Posts: 13
Joined: 26 September 2010

Re: Team project: C or C++ Explainer-like rating program

Postby StrmCkr » Sun Oct 03, 2010 8:11 am

To start with couldn't you add an option "File/Run File"

there is a function to load and rate a file :)

Who care if this version is fast
we do, currently specific puzzles will take 4+ hours to generate a single rating.

the goal is to update the the search functions using a better coding platform: either c++ or something else.
(add in the techniques that are newer, eliminate the known "rating bugs") among other issues with se.
Some do, some teach, the rest look it up.
stormdoku
User avatar
StrmCkr
 
Posts: 1433
Joined: 05 September 2006

Re: Team project: C or C++ Explainer-like rating program

Postby AR4793 » Sun Oct 03, 2010 1:12 pm

StrmCkr wrote:
To start with couldn't you add an option "File/Run File"

there is a function to load and rate a file :)

Who care if this version is fast
we do, currently specific puzzles will take 4+ hours to generate a single rating.

the goal is to update the the search functions using a better coding platform: either c++ or something else.
(add in the techniques that are newer, eliminate the known "rating bugs") among other issues with se.


Understand that the goal is to make it faster. But separate GUI and engine and when you come out with engine version 2 have a GUI version and a command line version. Version 1 still available for folks who want to test their puzzle with the current "gold standard." Only with a GUI with version 2 engine will you bury the discussion about which is right.

Regards,
Herb
AR4793
 
Posts: 13
Joined: 26 September 2010

PreviousNext

Return to Software