Page 2 of 2

This should be in the wiki

Posted: Wed Apr 13, 2016 5:05 pm
by sje
This should be in the wiki, if it's not already there.

The easiest way to test game termination detection is to add a chunk of code to generate lots of games, each made from randomly selected moves, and keep track of the counts of the different game termination kinds.

Generate a million such games, and the counts should be fairly close to:

Code: Select all

[] rg 1000000
   Checkmate   152806 0.152806
  FiftyMoves   223350 0.22335
Insufficient   536842 0.536842
  Repetition    25374 0.025374
   Stalemate    61628 0.061628
Average ply length: 341.998
Maximum ply length: 922
Which shows that repetition draws should occur about 2.54% of the time.

And some examples

Posted: Wed Apr 13, 2016 5:14 pm
by sje
And some examples:

To assist with testing, I've produced a PGN file of a thousand random games, of which 24 are repetition draws.

In each game, note the Termination tag pair which indicates the game termination kind.

https://dl.dropboxusercontent.com/u/316 ... 000.pgn.gz

Re: How to test 3rd repetition rule?

Posted: Thu Apr 14, 2016 2:12 am
by jswaff
In my Java engine chess4j, I pulled this logic out into a separate class and wrote a unit test to ensure that it works.

https://sourceforge.net/p/chess4j/code/ ... .java#l244

See 'testDrawRep()' at the bottom. It basically just starts with the opening position and plays through some moves, checking after each move whether it's a draw by rep or not.

I don't think I have anything that checks for a draw by rep within the context of a search but that satisfies me that the logic works, if I can manage to plug it in correctly.

Re: This should be in the wiki

Posted: Thu Apr 14, 2016 3:15 am
by Luis Babboni
sje wrote:This should be in the wiki, if it's not already there.

The easiest way to test game termination detection is to add a chunk of code to generate lots of games, each made from randomly selected moves, and keep track of the counts of the different game termination kinds.

Generate a million such games, and the counts should be fairly close to:

Code: Select all

[] rg 1000000
   Checkmate   152806 0.152806
  FiftyMoves   223350 0.22335
Insufficient   536842 0.536842
  Repetition    25374 0.025374
   Stalemate    61628 0.061628
Average ply length: 341.998
Maximum ply length: 922
Which shows that repetition draws should occur about 2.54% of the time.
Nice idea!!

Ten million

Posted: Thu Apr 14, 2016 4:38 am
by sje

Code: Select all

[] rg 10000000
   Checkmate  1530488 0.153049
  FiftyMoves  2240233 0.224023
Insufficient  5358465 0.535847
  Repetition   258098 0.0258098
   Stalemate   612716 0.0612716
Average ply length: 342.005
Maximum ply length: 1017

Re: How to test 3rd repetition rule?

Posted: Thu Apr 14, 2016 3:18 pm
by Werner Taelemans
flok wrote:The int is a counter and when that reaches 3 at some point in the search-tree...
It is OK to use the draw score when the counter reaches 2, as explained in this thread:
http://www.talkchess.com/forum/viewtopic.php?t=51000