From: Marco Costalba Date: Thu, 11 Jul 2013 05:22:26 +0000 (+0200) Subject: Fix a crash with depth 1 perft X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=366f6b0dabd392f7d0e4079b355615c726241596 Fix a crash with depth 1 perft Bug recently introduced in e215a88cddd16e09 No functional change. --- diff --git a/src/search.cpp b/src/search.cpp index af010502..c7798c87 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -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 it(pos); *it; ++it) { pos.do_move(*it, st, ci, pos.move_gives_check(*it, ci)); - cnt += leaf ? MoveList(pos).size() : perft(pos, depth - ONE_PLY); + cnt += leaf ? MoveList(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(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