projects
/
fairystockfish.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
(parent:
937bbe3
)
Speed-up pseudo-legal move validation of drops
author
Fabian Fichter
<ianfab@users.noreply.github.com>
Thu, 31 Jan 2019 20:14:47 +0000 (21:14 +0100)
committer
Fabian Fichter
<ianfab@users.noreply.github.com>
Fri, 1 Feb 2019 20:57:03 +0000 (21:57 +0100)
Improves performance by ~10% for drop variants.
src/position.cpp
patch
|
blob
|
history
diff --git
a/src/position.cpp
b/src/position.cpp
index
ee5b2f1
..
f7860fe
100644
(file)
--- 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<LEGAL>(*this).contains(m);