summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
20c2a31)
So to have a bit faster undo_move() and also
a code semplification.
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
st->materialKey = compute_material_key();
st->mgValue = compute_value<MidGame>();
st->egValue = compute_value<EndGame>();
st->materialKey = compute_material_key();
st->mgValue = compute_value<MidGame>();
st->egValue = compute_value<EndGame>();
- npMaterial[WHITE] = compute_non_pawn_material(WHITE);
- npMaterial[BLACK] = compute_non_pawn_material(BLACK);
+ st->npMaterial[WHITE] = compute_non_pawn_material(WHITE);
+ st->npMaterial[BLACK] = compute_non_pawn_material(BLACK);
}
/// Position::attacks_to() computes a bitboard containing all pieces which
}
/// Position::attacks_to() computes a bitboard containing all pieces which
-/// attacks a given square. There are two versions of this function: One
-/// which finds attackers of both colors, and one which only finds the
-/// attackers for one side.
+/// attacks a given square.
Bitboard Position::attacks_to(Square s) const {
Bitboard Position::attacks_to(Square s) const {
const bool Rook = (Piece == QUEEN || Piece == ROOK);
const bool Slider = Bishop || Rook;
const bool Rook = (Piece == QUEEN || Piece == ROOK);
const bool Slider = Bishop || Rook;
if ( ( (Bishop && bit_is_set(BishopPseudoAttacks[ksq], to))
|| (Rook && bit_is_set(RookPseudoAttacks[ksq], to)))
&& bit_is_set(piece_attacks<Piece>(ksq), to)) // slow, try to early skip
if ( ( (Bishop && bit_is_set(BishopPseudoAttacks[ksq], to))
|| (Rook && bit_is_set(RookPseudoAttacks[ksq], to)))
&& bit_is_set(piece_attacks<Piece>(ksq), to)) // slow, try to early skip
&& bit_is_set(piece_attacks<Piece>(ksq), to))
set_bit(pCheckersBB, to);
&& bit_is_set(piece_attacks<Piece>(ksq), to))
set_bit(pCheckersBB, to);
if (Piece != QUEEN && bit_is_set(dcCandidates, from))
{
if (Piece != ROOK)
if (Piece != QUEEN && bit_is_set(dcCandidates, from))
{
if (Piece != ROOK)
int castleRights, rule50;
Square epSquare;
Value mgValue, egValue;
int castleRights, rule50;
Square epSquare;
Value mgValue, egValue;
};
memcpy(&newSt, st, sizeof(ReducedStateInfo));
};
memcpy(&newSt, st, sizeof(ReducedStateInfo));
// Update material
if (capture != PAWN)
// Update material
if (capture != PAWN)
- npMaterial[them] -= piece_value_midgame(capture);
+ st->npMaterial[them] -= piece_value_midgame(capture);
// Update material hash key
st->materialKey ^= zobMaterial[them][capture][pieceCount[them][capture]];
// Update material hash key
st->materialKey ^= zobMaterial[them][capture][pieceCount[them][capture]];
st->capture = type_of_piece_on(to);
if (st->capture)
st->capture = type_of_piece_on(to);
if (st->capture)
- do_capture_move(st->capture, them, to);
+ do_capture_move(st->capture, them, to);
// Remove pawn
clear_bit(&(byColorBB[us]), from);
// Remove pawn
clear_bit(&(byColorBB[us]), from);
st->egValue += pst<EndGame>(us, promotion, to);
// Update material
st->egValue += pst<EndGame>(us, promotion, to);
// Update material
- npMaterial[us] += piece_value_midgame(promotion);
+ st->npMaterial[us] += piece_value_midgame(promotion);
// Clear the en passant square
if (st->epSquare != SQ_NONE)
// Clear the en passant square
if (st->epSquare != SQ_NONE)
set_bit(&(byTypeBB[0]), to);
board[to] = piece_of_color_and_type(them, st->capture);
set_bit(&(byTypeBB[0]), to);
board[to] = piece_of_color_and_type(them, st->capture);
- // Update material
- if (st->capture != PAWN)
- npMaterial[them] += piece_value_midgame(st->capture);
-
// Update piece list
pieceList[them][st->capture][pieceCount[them][st->capture]] = to;
index[to] = pieceCount[them][st->capture];
// Update piece list
pieceList[them][st->capture][pieceCount[them][st->capture]] = to;
index[to] = pieceCount[them][st->capture];
set_bit(&(byTypeBB[0]), from); // HACK: byTypeBB[0] == occupied squares
board[from] = piece_of_color_and_type(us, PAWN);
set_bit(&(byTypeBB[0]), from); // HACK: byTypeBB[0] == occupied squares
board[from] = piece_of_color_and_type(us, PAWN);
- // Update material
- npMaterial[us] -= piece_value_midgame(promotion);
-
// Update piece list
pieceList[us][PAWN][pieceCount[us][PAWN]] = from;
index[from] = pieceCount[us][PAWN];
// Update piece list
pieceList[us][PAWN][pieceCount[us][PAWN]] = from;
index[from] = pieceCount[us][PAWN];
set_bit(&(byTypeBB[0]), to); // HACK: byTypeBB[0] == occupied squares
board[to] = piece_of_color_and_type(them, st->capture);
set_bit(&(byTypeBB[0]), to); // HACK: byTypeBB[0] == occupied squares
board[to] = piece_of_color_and_type(them, st->capture);
- // Update material. Because the move is a promotion move, we know
- // that the captured piece cannot be a pawn.
- assert(st->capture != PAWN);
- npMaterial[them] += piece_value_midgame(st->capture);
-
// Update piece list
pieceList[them][st->capture][pieceCount[them][st->capture]] = to;
index[to] = pieceCount[them][st->capture];
// Update piece list
pieceList[them][st->capture][pieceCount[them][st->capture]] = to;
index[to] = pieceCount[them][st->capture];
set_bit(&(byTypeBB[0]), from);
board[from] = piece_of_color_and_type(us, PAWN);
set_bit(&(byTypeBB[0]), from);
board[from] = piece_of_color_and_type(us, PAWN);
pieceList[us][PAWN][index[to]] = from;
index[from] = index[to];
pieceList[them][PAWN][pieceCount[them][PAWN]] = capsq;
index[capsq] = pieceCount[them][PAWN];
pieceList[us][PAWN][index[to]] = from;
index[from] = index[to];
pieceList[them][PAWN][pieceCount[them][PAWN]] = capsq;
index[capsq] = pieceCount[them][PAWN];
pieceCount[them][PAWN]++;
}
pieceCount[them][PAWN]++;
}
st->egValue = compute_value<EndGame>();
// Material
st->egValue = compute_value<EndGame>();
// Material
- npMaterial[WHITE] = compute_non_pawn_material(WHITE);
- npMaterial[BLACK] = compute_non_pawn_material(BLACK);
+ st->npMaterial[WHITE] = compute_non_pawn_material(WHITE);
+ st->npMaterial[BLACK] = compute_non_pawn_material(BLACK);
if (failedStep) (*failedStep)++;
if (debugNonPawnMaterial)
{
if (failedStep) (*failedStep)++;
if (debugNonPawnMaterial)
{
- if (npMaterial[WHITE] != compute_non_pawn_material(WHITE))
+ if (st->npMaterial[WHITE] != compute_non_pawn_material(WHITE))
- if (npMaterial[BLACK] != compute_non_pawn_material(BLACK))
+ if (st->npMaterial[BLACK] != compute_non_pawn_material(BLACK))
int castleRights, rule50;
Square epSquare;
Value mgValue, egValue;
int castleRights, rule50;
Square epSquare;
Value mgValue, egValue;
PieceType capture;
Bitboard checkersBB;
PieceType capture;
Bitboard checkersBB;
Color sideToMove;
int gamePly;
Key history[MaxGameLength];
Color sideToMove;
int gamePly;
Key history[MaxGameLength];
File initialKFile, initialKRFile, initialQRFile;
StateInfo startState;
StateInfo* st;
File initialKFile, initialKRFile, initialQRFile;
StateInfo startState;
StateInfo* st;
}
inline Value Position::non_pawn_material(Color c) const {
}
inline Value Position::non_pawn_material(Color c) const {
+ return st->npMaterial[c];
}
inline Phase Position::game_phase() const {
}
inline Phase Position::game_phase() const {