Changes

Jump to: navigation, search

Perft

549 bytes added, 04:35, 25 April 2020
Perft function
</pre>
To speed up calculating, programs may consider to avoid avoiding making and unmaking moves for the last depth (depth == 1, before the brand ending).That may save a lot because leave nodes are always much more than the middle nodes. <pre>typedef unsigned long long u64; u64 Perft(int depth){ MOVE move_list[256]; int n_moves, i; u64 nodes = 0;  if (depth == 0) return 1;  n_moves = GenerateLegalMoves(move_list); for (i = 0; i < n_moves; i++) { if (depth == 1) nodes++; else { MakeMove(move_list[i]); nodes += Perft(depth - 1); UndoMove(move_list[i]); } } return nodes;}</pre>
==Perft function with pseudo move generator==
<span id="Bulk"></span>
 
=Bulk-counting=
Instead of counting nodes at "depth 0", legal move generators can take advantage of the fact that the number of moves generated at "depth 1" represents the accurate perft value for that branch. Therefore they can skip the last [[Make Move|makemove]]/[[Unmake Move|undomove]], which gives much faster results and is a better indicator of the raw move generator speed (versus move generator + make/unmake). However, this can cause some confusion when comparing perft values. Assuming the above code used a legal move generator, it would only need the following modification:

Navigation menu