Perft for Reversi

As can be seen in previous postings, the perft method is useful to verify the correctness of a move generator. The method traverses the game tree up to various, increasing depths to count all leaf nodes. The results are compared with pre-computed values to isolate bugs. Although the method originated in the chess programming community, the same debugging principle can be used for any board game with deterministic rules. So far, I have used perft to verify the move generation of Chess for Android and, thanks to Martin Fierz, also for Checkers for Android. I was unable to find pre-computed perft numbers for reversi, however.

Therefore, here is what is probably the debut of perft for reversi from the initial position, hopefully useful data for aspirant reversi programmers (at depths 9 and up, "passing" moves start to occur; at depths 11 and up, higher leaf nodes in which neither player can move start to occur).

DEPTH #LEAF NODES
========================
1 4
2 12
3 56
4 244
5 1396
6 8200
7 55092
8 390216
9 3005288
10 24571284
11 212258800
12 1939886636

Perft is also useful to analyze and improve the performance of a move generator. Today I made some optimizations in the reversi move generator that improve performance almost two-fold, posted as version 1.3.4 of Reversi for Android at the market.

Comments

Anonymous said…
Sorry, but not the first, check:

http://vivi.dyndns.org/d/5494
Aart Bik said…
Thanks for the link! I am happy to see the numbers confirmed. It's too bad the numbers stop at 10, since it would be interesting to see if their perft() would only count full depth leaf nodes (as done in chess), or count "higher" leaf nodes as well (which seems somewhat more logical in the context of reversi). See my presentation at Perft for Reversi.
Anonymous said…
DEPTH #LEAF NODES
========================
1 4
2 12
3 56
4 244
5 1396
6 8200
7 55092
8 390216
9 3005288
10 24571284
11 212258800
12 1939886636
13 18429641748
14 184042084512
15 1891832540064
16 20301186039128
Anonymous said…
I would like to point out for future programmers, these perft numbers count "passing" positions as a node whereas some implementations of makemove() may detect that its produced such a position and auto-pass, not allowing it to be a "node" in the gametree sense. Thats where I've been for 3 days wondering what my bug is. I dont have a bug. Neither do these guys. Count "pass" nodes to get the numbers here.
Richard DELORME said…
Hello, I am Richard Delorme, author of Edax, a well knows Othello program. I think your numbers are wrong. You count the terminal nodes (the ones were the game ends) several times. Here is a detailed perft, with internal nodes & terminal nodes (wins, draw & losses) up to depth 16:
nodes wins draws losses cumulative WDL Nodes + cumulative WDL
1 4 0 0 0 0 4
2 12 0 0 0 0 12
3 56 0 0 0 0 56
4 244 0 0 0 0 244
5 1396 0 0 0 0 1396
6 8200 0 0 0 0 8200
7 55092 0 0 0 0 55092
8 390216 0 0 0 0 390216
9 3005288 0 0 0 0 3005288
10 24571056 0 0 228 228 24571284
11 212258216 0 0 356 584 212258800
12 1939879668 0 0 6384 6968 1939886636
13 18429618408 0 0 16372 23340 18429641748
14 184041761768 0 0 299404 322744 184042084512
15 1891831332208 208 0 884904 1207856 1891832540064
16 20301171282452 128 0 13548692 14756676 20301186039128
For example at depth 16, you are counting the internal nodes + the WDL at depth 9, 10, 11, 12, 13, 14, 15 & 16. Personnally I think it is not correct to count the same nodes
Aart Bik said…
Thanks for your comment. Typically if a node can be reached through several paths, it is counted multiple times. De-dupping would require some bookkeeping. So I would not say that one or the other is wrong, it is just a matter of defining what is counted.

Popular posts from this blog

Connecting Chess for Android to a Remote Server

Connecting with the DGT Board

Chess for Android: UCI Engine Options