What is perft(x) exactly meaning?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

Jouni
Posts: 3283
Joined: Wed Mar 08, 2006 8:15 pm

What is perft(x) exactly meaning?

Post by Jouni »

Perft calculation got my interest and I ask:

Is it number of possible positions AFTER x plies? Or UNTIL x plies? Is it
counting DIFFERENT positions or ALL positions? Or is it may be actually counting different GAMES?

thanks Jouni
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

Re: What is perft(x) exactly meaning?

Post by sje »

Perft(n) is the number of different move paths of exactly length N from the given position, usually the initial array position.
User avatar
hgm
Posts: 27790
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: What is perft(x) exactly meaning?

Post by hgm »

It counts different games of exactly x plies. So if you are checkmated in less than x plies it does not count. But repdraws are ignored.
MattieShoes
Posts: 718
Joined: Fri Mar 20, 2009 8:59 pm

Re: What is perft(x) exactly meaning?

Post by MattieShoes »

for the initial position:
perft(0) == 1 (the root node)
perft(1) == 20 (20 legal moves from the initial position)
perft(2) == 400 (20 legal responses for each of the 20 legal moves)
etc.

Note node count is different than perft numbers. You'd expect the node count for perft(2) to be 421 due to 21 internal nodes.

The mates thing threw me off originally.
1. f4 e6
2. g4 Qh4#
Shows up in perft(4) but in perft(5)

The "correct" perft numbers can be found here
If you remove transpositions, it'd look more like this

There's a bunch of cross-referenced sequences related to chess there, though they're mostly just fun for curiosity's sake. :-)
User avatar
Matthias Gemuh
Posts: 3245
Joined: Thu Mar 09, 2006 9:10 am

Re: What is perft(x) exactly meaning?

Post by Matthias Gemuh »

It is the total number of legal moves at ply x, if all legal paths to ply x are considered.
My engine was quite strong till I added knowledge to it.
http://www.chess.hylogic.de
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: What is perft(x) exactly meaning?

Post by bob »

Jouni wrote:Perft calculation got my interest and I ask:

Is it number of possible positions AFTER x plies? Or UNTIL x plies? Is it
counting DIFFERENT positions or ALL positions? Or is it may be actually counting different GAMES?

thanks Jouni
It counts every node for a search to depth (n), counting each interior and tip node that is reached. It is not "iterative" so perft(5) does not include perft(1) through perft(4) nodes...
MattieShoes
Posts: 718
Joined: Fri Mar 20, 2009 8:59 pm

Re: What is perft(x) exactly meaning?

Post by MattieShoes »

Wat? Crafty does not count interior nodes in perft, only tips. perft(2) shows 400, not 421...