Changes

Jump to: navigation, search

Perft

123 bytes added, 04:29, 25 April 2020
no edit summary
return nodes;
}
</pre>
<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:
<pre>
...
//__/* DELETE: if (depth == 0) return 1; */__//
 
n_moves = GenerateMoves(move_list);
 
__if (depth == 1) return n_moves;__
...
</pre>
=Hashing= Perft can receive another To speed boost by [[Hash Table|hashing]] node countsup calculating, with a small chance programs may consider to avoid making and unmaking moves for inaccurate results. Sometimes this is used as a sanity check to make sure the hash table and keys are working correctlylast depth (depth == 1).
==Perft function with pseudo move generator== To generate legal moves some programs have to make moves first, call the function IsIncheck and then undo those moves. That makes the above Perft function to make and undo moves twice for all moves. Bellow code can avoid that problem and run much faster:
<pre>
typedef unsigned long long u64;
}
</pre>
 
<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:
<pre>
...
//__/* DELETE: if (depth == 0) return 1; */__//
 
n_moves = GenerateMoves(move_list);
 
__if (depth == 1) return n_moves;__
...
</pre>
 
=Hashing=
Perft can receive another speed boost by [[Hash Table|hashing]] node counts, with a small chance for inaccurate results. Sometimes this is used as a sanity check to make sure the hash table and keys are working correctly.
 
<span id="History"></span>
=Perft History=

Navigation menu