Perft and mate
Moderators: hgm, Rebel, chrisw
-
- Posts: 859
- Joined: Mon Aug 10, 2009 10:05 pm
- Location: Italy
- Full name: Stefano Gemma
Perft and mate
I've used the perft function of Crafty, to debug my new engine Freccia. One thing that i have noticed is that perft command just counts the moves at the final node. If, suppose, we want the perft at ply 6 we don't count any move that ends the game before that ply, like a mate in 2 does, for sample. Maybe perft is to be considered somehow... imperfect?
-
- Posts: 27794
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Perft and mate
Well, this is how perft(N) is defined: the number of N-move sequences. A mate-in-2 is not 6-move sequence.
-
- Posts: 859
- Joined: Mon Aug 10, 2009 10:05 pm
- Location: Italy
- Full name: Stefano Gemma
Re: Perft and mate
Ok, but i suppose a position in wich the mate is not forced so that you have some variation with mate in less than N plies and other moves that reach N plies. In this situation, perft does'nt count any variation that ends before N plies, for mate or stale mate. I think that perft would'nt give the best count for this positions. Maybe counting all plies or all moves could be better?
Re: Perft and mate
I think you are misunderstanding what perft is. It is not a search, it is purely move generation of legal moves. Take a very simple case:stegemma wrote:Ok, but i suppose a position in wich the mate is not forced so that you have some variation with mate in less than N plies and other moves that reach N plies. In this situation, perft does'nt count any variation that ends before N plies, for mate or stale mate. I think that perft would'nt give the best count for this positions. Maybe counting all plies or all moves could be better?
[D]1k6/6R1/1K6/8/8/8/8/8 w - - 0 14
perft 1 gives 19 nodes. Of those one is mate.
Now perft 2 gives a total of 53 nodes. One of those can only be seen to depth 1 since it's mate but the rest are the replies to the other 18 moves.
It doesn't matter to perft that a search can give up once it's found Rg8# because that's not what it's there for.
Andy.
-
- Posts: 859
- Joined: Mon Aug 10, 2009 10:05 pm
- Location: Italy
- Full name: Stefano Gemma
Re: Perft and mate
Ok... but perft 2 gives 34 moves.
Re: Perft and mate
I don't know if there is a "standard" but I add all moves at ply 1 to those at ply 2, etc.. 19+34 = 53.stegemma wrote:Ok... but perft 2 gives 34 moves.
Andy.
-
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: Perft and mate
It is not about "standard vs. non-standard" but about "correct vs. incorrect". The correct way is to count exactly all nodes at depth N. So in the given case, perft(2) = 34. Everything else is wrong.plattyaj wrote:I don't know if there is a "standard" but I add all moves at ply 1 to those at ply 2, etc.. 19+34 = 53.stegemma wrote:Ok... but perft 2 gives 34 moves.
Andy.
Note also that perft counts nodes, not moves. You can of course view it as counting the number of move paths exactly of length N.
See also this thread.
Sven
Re: Perft and mate
Thanks - that thread is somewhat newer than my implementation - if I remember right when I added it, some engines did it one way and some another. I'll add it to the long list of things to changeSven Schüle wrote:See also this thread
Andy.
-
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: Perft and mate
You should perhaps put it to the very top of that list ... With your current implementation, how can you compare your perft numbers with those published in the web?plattyaj wrote:Thanks - that thread is somewhat newer than my implementation - if I remember right when I added it, some engines did it one way and some another. I'll add it to the long list of things to changeSven Schüle wrote:See also this thread
Sven
Re: Perft and mate
Well, when I first compared them they had totals as well as by-ply so it was easy. Now I have to use math to add them up and make sure they compare.Sven Schüle wrote:You should perhaps put it to the very top of that list ... With your current implementation, how can you compare your perft numbers with those published in the web?
Andy.