Page 1 of 2
Perft and mate
Posted: Sun Aug 16, 2009 2:44 pm
by stegemma
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?
Re: Perft and mate
Posted: Sun Aug 16, 2009 3:23 pm
by hgm
Well, this is how perft(N) is defined: the number of N-move sequences. A mate-in-2 is not 6-move sequence.
Re: Perft and mate
Posted: Tue Aug 18, 2009 10:01 am
by stegemma
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
Posted: Tue Aug 18, 2009 1:16 pm
by plattyaj
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?
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:
[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.
Re: Perft and mate
Posted: Tue Aug 18, 2009 4:40 pm
by stegemma
Ok... but perft 2 gives 34 moves.
Re: Perft and mate
Posted: Tue Aug 18, 2009 4:55 pm
by plattyaj
stegemma wrote:Ok... but perft 2 gives 34 moves.
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.
Andy.
Re: Perft and mate
Posted: Tue Aug 18, 2009 7:01 pm
by Sven
plattyaj wrote:stegemma wrote:Ok... but perft 2 gives 34 moves.
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.
Andy.
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.
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
Posted: Tue Aug 18, 2009 7:11 pm
by plattyaj
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 change
Andy.
Re: Perft and mate
Posted: Tue Aug 18, 2009 7:18 pm
by Sven
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 change
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?
Sven
Re: Perft and mate
Posted: Tue Aug 18, 2009 7:41 pm
by plattyaj
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?
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.
Andy.