1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-01 01:03:09 +00:00

Fix a crash with depth 1 perft

Bug recently introduced in e215a88cdd

No functional change.
This commit is contained in:
Marco Costalba 2013-07-11 07:22:26 +02:00
parent 58aee9a9ea
commit 366f6b0dab

View file

@ -153,7 +153,7 @@ void Search::init() {
/// Search::perft() is our utility to verify move generation. All the leaf nodes /// 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. /// 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; StateInfo st;
size_t cnt = 0; size_t cnt = 0;
@ -163,12 +163,15 @@ size_t Search::perft(Position& pos, Depth depth) {
for (MoveList<LEGAL> it(pos); *it; ++it) for (MoveList<LEGAL> it(pos); *it; ++it)
{ {
pos.do_move(*it, st, ci, pos.move_gives_check(*it, ci)); 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); pos.undo_move(*it);
} }
return cnt; 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 /// 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 /// called by the main thread when the program receives the UCI 'go' command. It