Perft, leaf nodes?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Perft, leaf nodes?

Post by Luis Babboni »

Please say me where I´m wrong.
I understood that perft results are the number of leaf nodes (nodes that do not have more nodes beyond it, at least with perft number limit).
But I believe I found a position where at least Gaviota and Satana (the only engines I understand how to use to calculate perft) give me a result that is not the same I found "by hand".

This is the position:
7k/4R1pp/8/8/8/8/8/7K w - - 0 1

Image

Perft 2 gives me 73 in both engines (and in mine I´m working in) that is the number of leaf nodes without count the position after Re8++ that is, as far as I understood, a leaf node too.

Thanks!
User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Re: Perft, leaf nodes?

Post by Luis Babboni »

SOLVED!
Here is the correct definition of Perft:
Aleks Peshkov wrote: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.
User avatar
cdani
Posts: 2204
Joined: Sat Jan 18, 2014 10:24 am
Location: Andorra

Re: Perft, leaf nodes?

Post by cdani »

You can use for example Stockfish or Andscacs to calculate perft, too.

Just put
position fen 7k/4R1pp/8/8/8/8/8/7K w - - 0 1

and then
perft 2
User avatar
Ajedrecista
Posts: 1969
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: Perft, leaf nodes?

Post by Ajedrecista »

Hello Luis:
Luis Babboni wrote:SOLVED!
Here is the correct definition of Perft:
Aleks Peshkov wrote: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.
Here is, in fact, how JetChess perft counter reports perft(2) of that position:

Code: Select all

  1  Re7-e8           0
  2  Re7-f7           5
  3  Re7*g7           3
  4  Re7-d7           5
  5  Re7-c7           5
  6  Re7-b7           5
  7  Re7-a7           5
  8  Re7-e6           5
  9  Re7-e5           5
 10  Re7-e4           5
 11  Re7-e3           5
 12  Re7-e2           5
 13  Re7-e1           5
 14  Kh1-g1           5
 15  Kh1-g2           5
 16  Kh1-h2           5

Total:               73
Just to complete my post:

Code: Select all

 perft(1) =                        16
 perft(2) =                        73
 perft(3) =                     1,241
 perft(4) =                     5,861
 perft(5) =                   101,487
 perft(6) =                   539,658
 perft(7) =                 9,389,471
 perft(8) =                55,628,133
 perft(9) =               970,934,310
perft(10) =             6,203,290,408
perft(11) =           108,581,645,499
perft(12) =           731,006,640,533
perft(13) =        12,821,244,003,733
perft(14) =        89,335,944,621,556
perft(15) =     1,568,592,660,477,175
perft(16) =    11,198,005,325,037,030
perft(17) =   196,680,381,198,782,558
perft(18) = 1,431,536,409,060,656,547
I hope no typos.

Regards from Spain.

Ajedrecista.
User avatar
Luis Babboni
Posts: 464
Joined: Sat Feb 28, 2015 4:37 pm
Location: Argentina

Re: Perft, leaf nodes?

Post by Luis Babboni »

cdani wrote:You can use for example Stockfish or Andscacs to calculate perft, too.

Just put
position fen 7k/4R1pp/8/8/8/8/8/7K w - - 0 1

and then
perft 2
Thanks Daniel, I knew just "setboard" command! :P


Thanks Jesús!
Yes, I was wrong in the definition of perft.
If there is no ties or checkmates before the number in perft command, both are the same but was not the case.
brtzsnr
Posts: 433
Joined: Fri Jan 16, 2015 4:02 pm

Re: Perft, leaf nodes?

Post by brtzsnr »

You can also use zurichess, too: https://godoc.org/bitbucket.org/zurichess/tools/perft

Code: Select all

$ ./perft --fen "7k/4R1pp/8/8/8/8/8/7K w - - 0 1" --max_depth 10
Searching FEN "7k/4R1pp/8/8/8/8/8/7K w - - 0 1"
depth        nodes   captures enpassant castles   promotions eval  KNps   elapsed
-----+------------+----------+---------+---------+----------+-----+------+-------
    1           16          1         0         0          0        1722 9.289µs
    2           73          1         0         0          0        1808 40.381µs
    3         1241         44         0         0          0        5345 232.173µs
    4         5861         99         0         0          0        4758 1.2319ms
    5       101487       2192         0         0          0       17750 5.717569ms
    6       539658       9138         0         0          0       36895 14.627033ms
    7      9389471     176283         0         0          0      194111 48.371719ms
    8     55628133     886521         0         0          0      341662 162.816227ms
    9    970934310   18175344         0         0          0      722655 1.343566224s
   10   6203290408   92877449         0         0    1106664      493569 12.568227604s