mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 00:56:39 +08:00
Fix a crash with depth 1 perft
Bug recently introduced in e215a88cdd
No functional change.
This commit is contained in:
@@ -153,7 +153,7 @@ void Search::init() {
|
||||
/// Search::perft() is our utility to verify move generation. All the leaf nodes
|
||||
/// up to the given depth are generated and counted and the sum returned.
|
||||
|
||||
size_t Search::perft(Position& pos, Depth depth) {
|
||||
static size_t perft(Position& pos, Depth depth) {
|
||||
|
||||
StateInfo st;
|
||||
size_t cnt = 0;
|
||||
@@ -163,12 +163,15 @@ size_t Search::perft(Position& pos, Depth depth) {
|
||||
for (MoveList<LEGAL> it(pos); *it; ++it)
|
||||
{
|
||||
pos.do_move(*it, st, ci, pos.move_gives_check(*it, ci));
|
||||
cnt += leaf ? MoveList<LEGAL>(pos).size() : perft(pos, depth - ONE_PLY);
|
||||
cnt += leaf ? MoveList<LEGAL>(pos).size() : ::perft(pos, depth - ONE_PLY);
|
||||
pos.undo_move(*it);
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
size_t Search::perft(Position& pos, Depth depth) {
|
||||
return depth > ONE_PLY ? ::perft(pos, depth) : MoveList<LEGAL>(pos).size();
|
||||
}
|
||||
|
||||
/// Search::think() is the external interface to Stockfish's search, and is
|
||||
/// called by the main thread when the program receives the UCI 'go' command. It
|
||||
|
||||
Reference in New Issue
Block a user