1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 00:33:09 +00:00

Use CheckInfo to store pinned bitboard

This trivial change gives an impressive 2,5% speedup !!!!

Also retire one unused move_gives_check() overload.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2011-06-20 09:46:31 +02:00
parent 7ea38e980b
commit 018022b866
3 changed files with 13 additions and 20 deletions

View file

@ -90,13 +90,14 @@ CheckInfo::CheckInfo(const Position& pos) {
ksq = pos.king_square(them);
dcCandidates = pos.discovered_check_candidates(us);
pinned = pos.pinned_pieces(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[BISHOP] = pos.attacks_from<BISHOP>(ksq);
checkSq[ROOK] = pos.attacks_from<ROOK>(ksq);
checkSq[QUEEN] = checkSq[BISHOP] | checkSq[ROOK];
checkSq[KING] = EmptyBoardBB;
checkSq[ROOK] = pos.attacks_from<ROOK>(ksq);
checkSq[QUEEN] = checkSq[BISHOP] | checkSq[ROOK];
checkSq[KING] = EmptyBoardBB;
}
@ -746,11 +747,6 @@ bool Position::move_is_pl(const Move m) const {
/// Position::move_gives_check() tests whether a pseudo-legal move is a check
bool Position::move_gives_check(Move m) const {
return move_gives_check(m, CheckInfo(*this));
}
bool Position::move_gives_check(Move m, const CheckInfo& ci) const {
assert(is_ok());

View file

@ -41,6 +41,7 @@ struct CheckInfo {
explicit CheckInfo(const Position&);
Bitboard dcCandidates;
Bitboard pinned;
Bitboard checkSq[8];
Square ksq;
};
@ -187,7 +188,6 @@ public:
// Properties of moves
bool pl_move_is_legal(Move m, Bitboard pinned) const;
bool move_is_pl(const Move m) const;
bool move_gives_check(Move m) const;
bool move_gives_check(Move m, const CheckInfo& ci) const;
bool move_is_capture(Move m) const;
bool move_is_passed_pawn_push(Move m) const;

View file

@ -717,7 +717,6 @@ namespace {
StateInfo st;
const TTEntry *tte;
Key posKey;
Bitboard pinned;
Move ttMove, move, excludedMove, threatMove;
Depth ext, newDepth;
ValueType vt;
@ -918,12 +917,12 @@ namespace {
assert(rdepth >= ONE_PLY);
MovePicker mp(pos, ttMove, H, Position::see_value(pos.captured_piece_type()));
pinned = pos.pinned_pieces(pos.side_to_move());
CheckInfo ci(pos);
while ((move = mp.get_next_move()) != MOVE_NONE)
if (pos.pl_move_is_legal(move, pinned))
if (pos.pl_move_is_legal(move, ci.pinned))
{
pos.do_move(move, st);
pos.do_move(move, st, ci, pos.move_gives_check(move, ci));
value = -search<NonPV>(pos, ss+1, -rbeta, -rbeta+1, rdepth);
pos.undo_move(move);
if (value >= rbeta)
@ -951,7 +950,6 @@ split_point_start: // At split points actual search starts from here
// Initialize a MovePicker object for the current position
MovePickerExt<NT> mp(pos, ttMove, depth, H, ss, PvNode ? -VALUE_INFINITE : beta);
CheckInfo ci(pos);
pinned = pos.pinned_pieces(pos.side_to_move());
ss->bestMove = MOVE_NONE;
futilityBase = ss->eval + ss->evalMargin;
singularExtensionNode = !RootNode
@ -979,7 +977,7 @@ split_point_start: // At split points actual search starts from here
continue;
// At PV and SpNode nodes we want the moves to be legal
if ((PvNode || SpNode) && !pos.pl_move_is_legal(move, pinned))
if ((PvNode || SpNode) && !pos.pl_move_is_legal(move, ci.pinned))
continue;
if (SpNode)
@ -1026,7 +1024,7 @@ split_point_start: // At split points actual search starts from here
// a margin then we extend ttMove.
if ( singularExtensionNode
&& move == ttMove
&& pos.pl_move_is_legal(move, pinned)
&& pos.pl_move_is_legal(move, ci.pinned)
&& ext < ONE_PLY)
{
Value ttValue = value_from_tt(tte->value(), ss->ply);
@ -1101,7 +1099,7 @@ split_point_start: // At split points actual search starts from here
}
// Check for legality only before to do the move
if (!pos.pl_move_is_legal(move, pinned))
if (!pos.pl_move_is_legal(move, ci.pinned))
{
moveCount--;
continue;
@ -1395,7 +1393,6 @@ split_point_start: // At split points actual search starts from here
// be generated.
MovePicker mp(pos, ttMove, depth, H, move_to((ss-1)->currentMove));
CheckInfo ci(pos);
Bitboard pinned = pos.pinned_pieces(pos.side_to_move());
// Loop through the moves until no moves remain or a beta cutoff occurs
while ( alpha < beta
@ -1464,7 +1461,7 @@ split_point_start: // At split points actual search starts from here
}
// Check for legality only before to do the move
if (!pos.pl_move_is_legal(move, pinned))
if (!pos.pl_move_is_legal(move, ci.pinned))
continue;
// Update current move