Just take a look at this thread:
http://www.talkchess.com/forum/viewtopi ... ght=qperft
I've successfully compiled Muller's qperft in C++ and linked directly to my engine, when I was testing my perft (now I've removed the code from my engine).
I don't know if it works for C# too but maybe you can get a DLL from this code, on Windows.
Best way to debug perft?
Moderators: hgm, Rebel, chrisw
-
- Posts: 859
- Joined: Mon Aug 10, 2009 10:05 pm
- Location: Italy
- Full name: Stefano Gemma
Re: Best way to debug perft?
Author of Drago, Raffaela, Freccia, Satana, Sabrina.
http://www.linformatica.com
http://www.linformatica.com
-
- Posts: 10
- Joined: Wed Mar 11, 2015 9:42 pm
-
- Posts: 464
- Joined: Sat Feb 28, 2015 4:37 pm
- Location: Argentina
Re: Best way to debug perft?
Hello,
I´m pretty new in all this.
I´m trying to make a moves generator in basic and now I´m trying to know how to debug it so I found this topic.
A question:
as far as I understand (poor english here) you talk about compare moves, not just the number of moves that are legal from any position.
You are talking about list of moves?
What about if differents engines makes moves in different order?
Sorry if my question is a nonsense
Thanks.
I´m pretty new in all this.
I´m trying to make a moves generator in basic and now I´m trying to know how to debug it so I found this topic.
A question:
as far as I understand (poor english here) you talk about compare moves, not just the number of moves that are legal from any position.
You are talking about list of moves?
What about if differents engines makes moves in different order?
Sorry if my question is a nonsense
Thanks.
-
- Posts: 464
- Joined: Sat Feb 28, 2015 4:37 pm
- Location: Argentina
Re: Best way to debug perft?
Mmm, may be you could compare a list of FENs not necesary in the same order?
-
- Posts: 892
- Joined: Sun Nov 19, 2006 9:16 pm
- Location: Russia
Re: Best way to debug perft?
Perft is recursive number of legal moves.
Perft for depth 1 is number of legal moves from the given position.
Perft for depth N is sum of legal moves for all positions of Perft N-1.
Perft for depth 1 is number of legal moves from the given position.
Perft for depth N is sum of legal moves for all positions of Perft N-1.
-
- Posts: 859
- Joined: Mon Aug 10, 2009 10:05 pm
- Location: Italy
- Full name: Stefano Gemma
Re: Best way to debug perft?
You must count and sum all the legal "leaves" nodes. It is not the same as counting the Nth node moves, because some variant could lead to a mate before of depth N.
You could use an algorithm like this one:
Of course this an over-simplification; you can't return an int in 32 bit systems, because the number of moves could be larger than 32 bits signed, you need a legal move generator or just validate move after it has been executed and so on.
You could use an algorithm like this one:
Code: Select all
int Perft(int depth)
{
int legal_moves = MakeLegalMovesOnly();
if(GetMated() || IsStale()) return 1;
if(depth==0) return legal_moves;
int n = 0;
for(i=0; i<legal_moves; i++)
{
MakeMove(i);
n+= Perft(depth - 1);
UnMakeMove(i);
}
return n;
}
Author of Drago, Raffaela, Freccia, Satana, Sabrina.
http://www.linformatica.com
http://www.linformatica.com
-
- Posts: 27822
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Best way to debug perft?
Note that with the conventional definition of 'depth' you would return the number of moves if depth==1 (not 0), which is known as bulk counting, or return 1 at depth==0.
-
- Posts: 892
- Joined: Sun Nov 19, 2006 9:16 pm
- Location: Russia
Re: Best way to debug perft?
I am not sure that '1' is correct sum of empty set.hgm wrote:or return 1 at depth==0.
-
- Posts: 859
- Joined: Mon Aug 10, 2009 10:05 pm
- Location: Italy
- Full name: Stefano Gemma
Re: Best way to debug perft?
Right, if you start calling Perft(depth) and depth 1 is the root then you must correct my simple code with depth==1 instead of depth==0.hgm wrote:Note that with the conventional definition of 'depth' you would return the number of moves if depth==1 (not 0), which is known as bulk counting, or return 1 at depth==0.
For analogy with alphabeta I call Perft(depth-1), that's why my error.
Author of Drago, Raffaela, Freccia, Satana, Sabrina.
http://www.linformatica.com
http://www.linformatica.com
-
- Posts: 464
- Joined: Sat Feb 28, 2015 4:37 pm
- Location: Argentina
Re: Best way to debug perft?
Thanks!
Now I think the numbers are too big to have "a list" of FENs to compare with.
I read something more and it seems not as easy as I thought, perft matter is a world in itself!
It seems I need to improve my program to make it more automatically in gives results. Even initial position is needed to be entered too manually.
BTW.
Look at this, where I´m wrong?
I tried perft 1 in Sharper, an engine recommended in other post to use for comparing, and gives me 20 where my generator and even by hand you could count 21 possible moves :
What other engine could I use to have perfts?
Now I think the numbers are too big to have "a list" of FENs to compare with.
I read something more and it seems not as easy as I thought, perft matter is a world in itself!
It seems I need to improve my program to make it more automatically in gives results. Even initial position is needed to be entered too manually.
BTW.
Look at this, where I´m wrong?
I tried perft 1 in Sharper, an engine recommended in other post to use for comparing, and gives me 20 where my generator and even by hand you could count 21 possible moves :
What other engine could I use to have perfts?