From 0e7e3b244a33aa19e215e115249b20976db42a62 Mon Sep 17 00:00:00 2001 From: Fabian Fichter Date: Thu, 31 Jan 2019 21:14:47 +0100 Subject: [PATCH] Speed-up pseudo-legal move validation of drops Improves performance by ~10% for drop variants. --- src/position.cpp | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index ee5b2f1..f7860fe 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -831,6 +831,14 @@ bool Position::pseudo_legal(const Move m) const { Square to = to_sq(m); Piece pc = moved_piece(m); + // Use a fast check for piece drops + if (type_of(m) == DROP) + return piece_drops() + && count_in_hand(us, type_of(pc)) + && (drop_region(us, type_of(pc)) & ~pieces() & to) + && ( type_of(pc) == in_hand_piece_type(m) + || (drop_promoted() && promoted_piece_type(type_of(pc)) == in_hand_piece_type(m))); + // Use a slower but simpler function for uncommon cases if (type_of(m) != NORMAL) return MoveList(*this).contains(m); -- 1.7.0.4