Speed up move generation
authorFabian Fichter <ianfab@users.noreply.github.com>
Fri, 26 Feb 2021 16:52:49 +0000 (17:52 +0100)
committerFabian Fichter <ianfab@users.noreply.github.com>
Fri, 26 Feb 2021 16:52:49 +0000 (17:52 +0100)
standard STC
LLR: -2.97 (-2.94,2.94) [0.00,10.00]
Total: 7654 W: 1715 L: 1705 D: 4234
http://www.variantfishtest.org:6543/tests/view/60341b906e23db669974e955

seirawan STC
LLR: -2.97 (-2.94,2.94) [0.00,10.00]
Total: 7286 W: 2480 L: 2464 D: 2342
http://www.variantfishtest.org:6543/tests/view/6034b1936e23db669974e962

minishogi STC
LLR: -2.96 (-2.94,2.94) [0.00,10.00]
Total: 9644 W: 4840 L: 4804 D: 0
http://www.variantfishtest.org:6543/tests/view/6034b1796e23db669974e960

bench: 4387985

src/position.h

index 42022e2..5ac26ef 100644 (file)
@@ -976,6 +976,9 @@ inline Square Position::castling_rook_square(CastlingRights cr) const {
 }
 
 inline Bitboard Position::attacks_from(Color c, PieceType pt, Square s) const {
+  if (var->fastAttacks || var->fastAttacks2)
+      return attacks_bb(c, pt, s, byTypeBB[ALL_PIECES]) & board_bb();
+
   PieceType movePt = pt == KING ? king_type() : pt;
   Bitboard b = attacks_bb(c, movePt, s, byTypeBB[ALL_PIECES]);
   // Xiangqi soldier
@@ -1004,6 +1007,9 @@ inline Bitboard Position::attacks_from(Color c, PieceType pt, Square s) const {
 }
 
 inline Bitboard Position::moves_from(Color c, PieceType pt, Square s) const {
+  if (var->fastAttacks || var->fastAttacks2)
+      return moves_bb(c, pt, s, byTypeBB[ALL_PIECES]) & board_bb();
+
   PieceType movePt = pt == KING ? king_type() : pt;
   Bitboard b = moves_bb(c, movePt, s, byTypeBB[ALL_PIECES]);
   // Xiangqi soldier