From 483a2576185a8158bef8ac97bb013258afb1b64a Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Wed, 4 Nov 2009 11:11:04 +0100 Subject: [PATCH] Speed up perft There is no need to do / undo the move at the last ply No functional change. Signed-off-by: Marco Costalba --- src/search.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 3e4341c0..c323de5d 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -332,14 +332,19 @@ namespace { int perft(Position& pos, Depth depth) { - if (depth <= Depth(0)) // Replace with '<' to test also qsearch - return 1; - Move move; MovePicker mp = MovePicker(pos, MOVE_NONE, depth, H); Bitboard dcCandidates = mp.discovered_check_candidates(); int sum = 0; + // If we are at the last ply we don't need to do and undo + // the moves, just to count them. + if (depth <= OnePly) // Replace with '<' to test also qsearch + { + while ((move = mp.get_next_move()) != MOVE_NONE) sum++; + return sum; + } + // Loop through all legal moves while ((move = mp.get_next_move()) != MOVE_NONE) { -- 2.39.2