1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-01 01:03:09 +00:00

Convert move_is_check() to take a CheckInfo reference

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2009-11-09 21:02:07 +01:00
parent 30075e4abc
commit 975d5e9c64
3 changed files with 17 additions and 14 deletions

View file

@ -65,7 +65,7 @@ CheckInfo::CheckInfo(const Position& pos) {
Color them = opposite_color(us); Color them = opposite_color(us);
ksq = pos.king_square(them); ksq = pos.king_square(them);
dc = pos.discovered_check_candidates(us); dcCandidates = pos.discovered_check_candidates(us);
checkSq[PAWN] = pos.attacks_from<PAWN>(ksq, them); checkSq[PAWN] = pos.attacks_from<PAWN>(ksq, them);
checkSq[KNIGHT] = pos.attacks_from<KNIGHT>(ksq); checkSq[KNIGHT] = pos.attacks_from<KNIGHT>(ksq);
@ -552,11 +552,12 @@ bool Position::pl_move_is_evasion(Move m, Bitboard pinned) const
bool Position::move_is_check(Move m) const { bool Position::move_is_check(Move m) const {
Bitboard dc = discovered_check_candidates(side_to_move()); return move_is_check(m, CheckInfo(*this));
return move_is_check(m, dc);
} }
bool Position::move_is_check(Move m, Bitboard dcCandidates) const { bool Position::move_is_check(Move m, const CheckInfo& ci) const {
Bitboard dcCandidates = ci.dcCandidates;
assert(is_ok()); assert(is_ok());
assert(move_is_ok(m)); assert(move_is_ok(m));

View file

@ -71,7 +71,7 @@ struct CheckInfo {
CheckInfo(const Position&); CheckInfo(const Position&);
Square ksq; Square ksq;
Bitboard dc; Bitboard dcCandidates;
Bitboard checkSq[8]; Bitboard checkSq[8];
}; };
@ -218,7 +218,7 @@ public:
bool pl_move_is_legal(Move m, Bitboard pinned) const; bool pl_move_is_legal(Move m, Bitboard pinned) const;
bool pl_move_is_evasion(Move m, Bitboard pinned) const; bool pl_move_is_evasion(Move m, Bitboard pinned) const;
bool move_is_check(Move m) const; bool move_is_check(Move m) const;
bool move_is_check(Move m, Bitboard dcCandidates) const; bool move_is_check(Move m, const CheckInfo& ci) const;
bool move_is_capture(Move m) const; bool move_is_capture(Move m) const;
bool move_is_capture_or_promotion(Move m) const; bool move_is_capture_or_promotion(Move m) const;
bool move_is_passed_pawn_push(Move m) const; bool move_is_passed_pawn_push(Move m) const;

View file

@ -1115,7 +1115,7 @@ namespace {
isCheck = pos.is_check(); isCheck = pos.is_check();
mateThreat = pos.has_mate_threat(opposite_color(pos.side_to_move())); mateThreat = pos.has_mate_threat(opposite_color(pos.side_to_move()));
CheckInfo ci(pos); CheckInfo ci(pos);
dcCandidates = ci.dc; dcCandidates = ci.dcCandidates;
MovePicker mp = MovePicker(pos, ttMove, depth, H, &ss[ply]); MovePicker mp = MovePicker(pos, ttMove, depth, H, &ss[ply]);
// Loop through all legal moves until no moves remain or a beta cutoff // Loop through all legal moves until no moves remain or a beta cutoff
@ -1127,7 +1127,7 @@ namespace {
assert(move_is_ok(move)); assert(move_is_ok(move));
singleReply = (isCheck && mp.number_of_evasions() == 1); singleReply = (isCheck && mp.number_of_evasions() == 1);
moveIsCheck = pos.move_is_check(move, dcCandidates); moveIsCheck = pos.move_is_check(move, ci);
captureOrPromotion = pos.move_is_capture_or_promotion(move); captureOrPromotion = pos.move_is_capture_or_promotion(move);
movesSearched[moveCount++] = ss[ply].currentMove = move; movesSearched[moveCount++] = ss[ply].currentMove = move;
@ -1373,7 +1373,7 @@ namespace {
// to search all moves. // to search all moves.
MovePicker mp = MovePicker(pos, ttMove, depth, H, &ss[ply]); MovePicker mp = MovePicker(pos, ttMove, depth, H, &ss[ply]);
CheckInfo ci(pos); CheckInfo ci(pos);
dcCandidates = ci.dc; dcCandidates = ci.dcCandidates;
futilityValue = VALUE_NONE; futilityValue = VALUE_NONE;
useFutilityPruning = depth < SelectiveDepth && !isCheck; useFutilityPruning = depth < SelectiveDepth && !isCheck;
@ -1390,7 +1390,7 @@ namespace {
assert(move_is_ok(move)); assert(move_is_ok(move));
singleReply = (isCheck && mp.number_of_evasions() == 1); singleReply = (isCheck && mp.number_of_evasions() == 1);
moveIsCheck = pos.move_is_check(move, dcCandidates); moveIsCheck = pos.move_is_check(move, ci);
captureOrPromotion = pos.move_is_capture_or_promotion(move); captureOrPromotion = pos.move_is_capture_or_promotion(move);
movesSearched[moveCount++] = ss[ply].currentMove = move; movesSearched[moveCount++] = ss[ply].currentMove = move;
@ -1595,7 +1595,7 @@ namespace {
// queen promotions and checks (only if depth == 0) will be generated. // queen promotions and checks (only if depth == 0) will be generated.
MovePicker mp = MovePicker(pos, ttMove, depth, H); MovePicker mp = MovePicker(pos, ttMove, depth, H);
CheckInfo ci(pos); CheckInfo ci(pos);
dcCandidates = ci.dc; dcCandidates = ci.dcCandidates;
enoughMaterial = pos.non_pawn_material(pos.side_to_move()) > RookValueMidgame; enoughMaterial = pos.non_pawn_material(pos.side_to_move()) > RookValueMidgame;
// Loop through the moves until no moves remain or a beta cutoff // Loop through the moves until no moves remain or a beta cutoff
@ -1613,7 +1613,7 @@ namespace {
&& !isCheck && !isCheck
&& !pvNode && !pvNode
&& !move_is_promotion(move) && !move_is_promotion(move)
&& !pos.move_is_check(move, dcCandidates) && !pos.move_is_check(move, ci)
&& !pos.move_is_passed_pawn_push(move)) && !pos.move_is_passed_pawn_push(move))
{ {
futilityValue = staticValue futilityValue = staticValue
@ -1701,6 +1701,7 @@ namespace {
assert(ActiveThreads > 1); assert(ActiveThreads > 1);
Position pos = Position(sp->pos); Position pos = Position(sp->pos);
CheckInfo ci(pos);
SearchStack* ss = sp->sstack[threadID]; SearchStack* ss = sp->sstack[threadID];
Value value; Value value;
Move move; Move move;
@ -1714,7 +1715,7 @@ namespace {
{ {
assert(move_is_ok(move)); assert(move_is_ok(move));
bool moveIsCheck = pos.move_is_check(move, sp->dcCandidates); bool moveIsCheck = pos.move_is_check(move, ci);
bool captureOrPromotion = pos.move_is_capture_or_promotion(move); bool captureOrPromotion = pos.move_is_capture_or_promotion(move);
lock_grab(&(sp->lock)); lock_grab(&(sp->lock));
@ -1844,6 +1845,7 @@ namespace {
assert(ActiveThreads > 1); assert(ActiveThreads > 1);
Position pos = Position(sp->pos); Position pos = Position(sp->pos);
CheckInfo ci(pos);
SearchStack* ss = sp->sstack[threadID]; SearchStack* ss = sp->sstack[threadID];
Value value; Value value;
Move move; Move move;
@ -1852,7 +1854,7 @@ namespace {
&& !thread_should_stop(threadID) && !thread_should_stop(threadID)
&& (move = sp->mp->get_next_move(sp->lock)) != MOVE_NONE) && (move = sp->mp->get_next_move(sp->lock)) != MOVE_NONE)
{ {
bool moveIsCheck = pos.move_is_check(move, sp->dcCandidates); bool moveIsCheck = pos.move_is_check(move, ci);
bool captureOrPromotion = pos.move_is_capture_or_promotion(move); bool captureOrPromotion = pos.move_is_capture_or_promotion(move);
assert(move_is_ok(move)); assert(move_is_ok(move));