Speed-up for variants with mandatory captures.
giveaway STC
LLR: 2.94 (-2.94,2.94) [0.00,10.00]
Total: 1873 W: 743 L: 637 D: 493
http://www.variantfishtest.org:6543/tests/view/
5fc2239d6e23db221d9e9423
losers STC
LLR: 2.95 (-2.94,2.94) [0.00,10.00]
Total: 1194 W: 577 L: 469 D: 148
http://www.variantfishtest.org:6543/tests/view/
5fc223af6e23db221d9e9426
No functional change.
si->checkSquares[KING] = 0;
si->shak = si->checkersBB & (byTypeBB[KNIGHT] | byTypeBB[ROOK] | byTypeBB[BERS]);
si->bikjang = var->bikjangRule && ksq != SQ_NONE ? bool(attacks_bb(sideToMove, ROOK, ksq, pieces()) & pieces(sideToMove, KING)) : false;
+ si->legalCapture = NO_VALUE;
}
return false;
// Illegal quiet moves
- if (must_capture() && !capture(m))
+ if (must_capture() && !capture(m) && st->legalCapture != VALUE_FALSE)
{
+ // Check for cached value
+ if (st->legalCapture == VALUE_TRUE)
+ return false;
if (checkers())
{
for (const auto& mevasion : MoveList<EVASIONS>(*this))
if (capture(mevasion) && legal(mevasion))
+ {
+ st->legalCapture = VALUE_TRUE;
return false;
+ }
}
else
{
for (const auto& mcap : MoveList<CAPTURES>(*this))
if (capture(mcap) && legal(mcap))
+ {
+ st->legalCapture = VALUE_TRUE;
return false;
+ }
}
+ st->legalCapture = VALUE_FALSE;
}
// Illegal non-drop moves
#include "evaluate.h"
#include "types.h"
#include "variant.h"
+#include "movegen.h"
#include "nnue/nnue_accumulator.h"
Bitboard pinners[COLOR_NB];
Bitboard checkSquares[PIECE_TYPE_NB];
Bitboard flippedPieces;
+ OptBool legalCapture;
bool capturedpromoted;
bool shak;
bool bikjang;
bool checking_permitted() const;
bool drop_checks() const;
bool must_capture() const;
+ bool has_capture() const;
bool must_drop() const;
bool piece_drops() const;
bool drop_loop() const;
return var->mustCapture;
}
+inline bool Position::has_capture() const {
+ return st->legalCapture == VALUE_TRUE || (st->legalCapture == NO_VALUE && MoveList<CAPTURES>(*this).size());
+}
+
inline bool Position::must_drop() const {
assert(var != nullptr);
return var->mustDrop;
: ss->staticEval > (ss-2)->staticEval;
// Skip early pruning in case of mandatory capture
- if (pos.must_capture() && MoveList<CAPTURES>(pos).size())
+ if (pos.must_capture() && pos.has_capture())
goto moves_loop;
// Step 8. Futility pruning: child node (~50 Elo)
|| ss->staticEval + PieceValue[EG][pos.captured_piece()] <= alpha
|| cutNode
|| thisThread->ttHitAverage < 427 * TtHitAverageResolution * TtHitAverageWindow / 1024)
- && !(pos.must_capture() && (givesCheck || MoveList<CAPTURES>(pos).size())))
+ && !(pos.must_capture() && (givesCheck || pos.has_capture())))
{
Depth r = reduction(improving, depth, moveCount);
NO_ENCLOSING, REVERSI, ATAXX
};
+enum OptBool {
+ NO_VALUE, VALUE_FALSE, VALUE_TRUE
+};
+
enum Phase {
PHASE_ENDGAME,
PHASE_MIDGAME = 128,