perft

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Daniel Anulliero
Posts: 759
Joined: Fri Jan 04, 2013 4:55 pm
Location: Nice

perft

Post by Daniel Anulliero »

hi all!

I try to debug my program since long time lol
I would like to know if my movegen is bug free (!) I ran some perft positions from wiki with nodes by type moves ( castle , ep etc ..)
Strange thing , I have the good number of nodes but many erros with nodes number by type moves...
I built my perft function on the wiki pseudo code , I think is bugfree...lol
Do you know a program who give all nodes (by type moves) for every positions setup by the user ?
I'm so disapointed when I saw that my genmove (and maybe make and unmake too) function is all buggy , some help is welcome ;-)
bye all!
Isa download :
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: perft

Post by syzygy »

Daniel Anulliero wrote:I would like to know if my movegen is bug free (!) I ran some perft positions from wiki with nodes by type moves ( castle , ep etc ..)
Strange thing , I have the good number of nodes but many erros with nodes number by type moves...
You might just be counting the various types of moves differently, so ignore that.

Concentrate on the perft counts and test more positions. If there is one count that deviates from the correct count as reported by the various perft implementations around, then find and fix the bug in your code.
flok

Re: perft

Post by flok »

syzygy wrote:Concentrate on the perft counts and test more positions. If there is one count that deviates from the correct count as reported by the various perft implementations around, then find and fix the bug in your code.
Am I right that those perft-values not always follow the correct rules, e.g. that occasionally when using the validation of the moves is too strict, that different values are returned?

For example:

Code: Select all

8/3K4/2p5/p2b2r1/5k2/8/8/1q6 b - -
With my program it finds 6 nodes, while the webpage I got this perft from says it should be 50.
Daniel Anulliero
Posts: 759
Joined: Fri Jan 04, 2013 4:55 pm
Location: Nice

Re: perft

Post by Daniel Anulliero »

hi
thx for your reply ronald
But can you explain better why I can ignore the results for each type of moves ? My program have not the same number of captures too for example , it must be the same no ?

folkert , welcome to the "perft brain break" ;-) !
Isa download :
mar
Posts: 2559
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: perft

Post by mar »

There was a thread about some artificial test positions that should help to find many pitfalls: http://talkchess.com/forum/viewtopic.ph ... t&start=15
It might help you.
Daniel Anulliero
Posts: 759
Joined: Fri Jan 04, 2013 4:55 pm
Location: Nice

Re: perft

Post by Daniel Anulliero »

thx for the link martin :-)
Isa download :
rreagan
Posts: 102
Joined: Sun Sep 09, 2007 6:32 am

Re: perft

Post by rreagan »

flok wrote:
syzygy wrote:Concentrate on the perft counts and test more positions. If there is one count that deviates from the correct count as reported by the various perft implementations around, then find and fix the bug in your code.
Am I right that those perft-values not always follow the correct rules, e.g. that occasionally when using the validation of the moves is too strict, that different values are returned?

For example:

Code: Select all

8/3K4/2p5/p2b2r1/5k2/8/8/1q6 b - -
With my program it finds 6 nodes, while the webpage I got this perft from says it should be 50.
Perft is like a calculator. If your calculator says 2+2=5 then it has a bug.

Perft is always an exact calculation. If it's different by even 1 then you have a bug somewhere.
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: perft

Post by syzygy »

flok wrote:
syzygy wrote:Concentrate on the perft counts and test more positions. If there is one count that deviates from the correct count as reported by the various perft implementations around, then find and fix the bug in your code.
Am I right that those perft-values not always follow the correct rules, e.g. that occasionally when using the validation of the moves is too strict, that different values are returned?

For example:

Code: Select all

8/3K4/2p5/p2b2r1/5k2/8/8/1q6 b - -
With my program it finds 6 nodes, while the webpage I got this perft from says it should be 50.
I'm afraid even your FEN parsing code is full of bugs.
mar
Posts: 2559
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: perft

Post by mar »

flok wrote:With my program it finds 6 nodes, while the webpage I got this perft from says it should be 50.
Check your FEN parser. It's possible that it swaps side to move (or even black and white pieces :)
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: perft

Post by syzygy »

Daniel Anulliero wrote:hi
thx for your reply ronald
But can you explain better why I can ignore the results for each type of moves ? My program have not the same number of captures too for example , it must be the same no ?
Only if you count them in exactly the same way. If your total perft results are always correct, then you can be pretty sure that your move generator is correct. (Of course it is difficult to know that it is *always* correct, so be sure to test it on positions that test most of the special cases.)

Captures can be counted in many ways:
- including or excluding en passant;
- including or excluding promotion captures;
- only in the leaves or including "internal" captures.

You can try to find out why the capture counts differ if it really bugs you, but it is not pointing to a bug unless you are certain that you count captures in the same way.