summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
37fa8ad)
No functional change.
Signed-off-by: Marco Costalba <mcostalba@gmail.com>
if ( pos.piece_count(strongerSide, QUEEN)
|| pos.piece_count(strongerSide, ROOK)
if ( pos.piece_count(strongerSide, QUEEN)
|| pos.piece_count(strongerSide, ROOK)
- || pos.both_color_bishops(strongerSide)) {
+ || pos.bishop_pair(strongerSide)) {
result += VALUE_KNOWN_WIN;
}
result += VALUE_KNOWN_WIN;
}
// Initialize score by reading the incrementally updated scores included
// in the position object (material + piece square tables).
// Initialize score by reading the incrementally updated scores included
// in the position object (material + piece square tables).
+ score = pos.psq_score();
// margins[] store the uncertainty estimation of position's evaluation
// that typically is used by the search for pruning decisions.
margins[WHITE] = margins[BLACK] = VALUE_ZERO;
// Probe the material hash table
// margins[] store the uncertainty estimation of position's evaluation
// that typically is used by the search for pruning decisions.
margins[WHITE] = margins[BLACK] = VALUE_ZERO;
// Probe the material hash table
- ei.mi = Threads[pos.thread()].materialTable.probe(pos);
+ ei.mi = Threads[pos.this_thread()].materialTable.probe(pos);
score += ei.mi->material_value();
// If we have a specialized evaluation function for the current material
score += ei.mi->material_value();
// If we have a specialized evaluation function for the current material
}
// Probe the pawn hash table
}
// Probe the pawn hash table
- ei.pi = Threads[pos.thread()].pawnTable.probe(pos);
+ ei.pi = Threads[pos.this_thread()].pawnTable.probe(pos);
score += ei.pi->pawns_value();
// Initialize attack and king safety bitboards
score += ei.pi->pawns_value();
// Initialize attack and king safety bitboards
// If we don't already have an unusual scale factor, check for opposite
// colored bishop endgames, and use a lower scale for those.
if ( ei.mi->game_phase() < PHASE_MIDGAME
// If we don't already have an unusual scale factor, check for opposite
// colored bishop endgames, and use a lower scale for those.
if ( ei.mi->game_phase() < PHASE_MIDGAME
- && pos.opposite_colored_bishops()
+ && pos.opposite_bishops()
&& sf == SCALE_FACTOR_NORMAL)
{
// Only the two bishops ?
&& sf == SCALE_FACTOR_NORMAL)
{
// Only the two bishops ?
// In case of tracing add all single evaluation contributions for both white and black
if (Trace)
{
// In case of tracing add all single evaluation contributions for both white and black
if (Trace)
{
- trace_add(PST, pos.value());
+ trace_add(PST, pos.psq_score());
trace_add(IMBALANCE, ei.mi->material_value());
trace_add(PAWN, ei.pi->pawns_value());
trace_add(MOBILITY, apply_weight(mobilityWhite, Weights[Mobility]), apply_weight(mobilityBlack, Weights[Mobility]));
trace_add(IMBALANCE, ei.mi->material_value());
trace_add(PAWN, ei.pi->pawns_value());
trace_add(MOBILITY, apply_weight(mobilityWhite, Weights[Mobility]), apply_weight(mobilityBlack, Weights[Mobility]));
Square d = pawn_push(Us) + (file_of(s) == FILE_A ? DELTA_E : DELTA_W);
if (pos.piece_on(s + d) == make_piece(Us, PAWN))
{
Square d = pawn_push(Us) + (file_of(s) == FILE_A ? DELTA_E : DELTA_W);
if (pos.piece_on(s + d) == make_piece(Us, PAWN))
{
- if (!pos.square_is_empty(s + d + pawn_push(Us)))
+ if (!pos.square_empty(s + d + pawn_push(Us)))
score -= 2*TrappedBishopA1H1Penalty;
else if (pos.piece_on(s + 2*d) == make_piece(Us, PAWN))
score -= TrappedBishopA1H1Penalty;
score -= 2*TrappedBishopA1H1Penalty;
else if (pos.piece_on(s + 2*d) == make_piece(Us, PAWN))
score -= TrappedBishopA1H1Penalty;
ebonus -= Value(square_distance(pos.king_square(Us), blockSq + pawn_push(Us)) * rr);
// If the pawn is free to advance, increase bonus
ebonus -= Value(square_distance(pos.king_square(Us), blockSq + pawn_push(Us)) * rr);
// If the pawn is free to advance, increase bonus
- if (pos.square_is_empty(blockSq))
+ if (pos.square_empty(blockSq))
{
squaresToQueen = squares_in_front_of(Us, s);
defendedSquares = squaresToQueen & ei.attackedBy[Us][0];
{
squaresToQueen = squares_in_front_of(Us, s);
defendedSquares = squaresToQueen & ei.attackedBy[Us][0];
namespace {
// Bonus for having the side to move (modified by Joona Kiiski)
namespace {
// Bonus for having the side to move (modified by Joona Kiiski)
- const Score TempoValue = make_score(48, 22);
+ const Score Tempo = make_score(48, 22);
// To convert a Piece to and from a FEN char
const string PieceToChar(" PNBRQK pnbrqk .");
// To convert a Piece to and from a FEN char
const string PieceToChar(" PNBRQK pnbrqk .");
st->key = compute_key();
st->pawnKey = compute_pawn_key();
st->materialKey = compute_material_key();
st->key = compute_key();
st->pawnKey = compute_pawn_key();
st->materialKey = compute_material_key();
- st->value = compute_value();
+ st->psqScore = compute_psq_score();
st->npMaterial[WHITE] = compute_non_pawn_material(WHITE);
st->npMaterial[BLACK] = compute_non_pawn_material(BLACK);
st->checkersBB = attackers_to(king_square(sideToMove)) & pieces(~sideToMove);
st->npMaterial[WHITE] = compute_non_pawn_material(WHITE);
st->npMaterial[BLACK] = compute_non_pawn_material(BLACK);
st->checkersBB = attackers_to(king_square(sideToMove)) & pieces(~sideToMove);
{
sq = make_square(file, rank);
{
sq = make_square(file, rank);
- if (square_is_empty(sq))
- Position p(*this, thread());
+ Position p(*this, this_thread());
cout << "\nMove is: " << (sideToMove == BLACK ? ".." : "") << move_to_san(p, move);
}
cout << "\nMove is: " << (sideToMove == BLACK ? ".." : "") << move_to_san(p, move);
}
Square to = to_sq(m);
Piece piece = piece_moved(m);
Square to = to_sq(m);
Piece piece = piece_moved(m);
- assert(!square_is_empty(from));
+ assert(!square_empty(from));
// Update occupancy as if the piece is moving
occ = pieces() ^ from ^ to;
// Update occupancy as if the piece is moving
occ = pieces() ^ from ^ to;
case DELTA_N:
case DELTA_S:
// Pawn push. The destination square must be empty.
case DELTA_N:
case DELTA_S:
// Pawn push. The destination square must be empty.
- if (!square_is_empty(to))
// rank, and both the destination square and the square between the
// source and destination squares must be empty.
if ( rank_of(to) != RANK_4
// rank, and both the destination square and the square between the
// source and destination squares must be empty.
if ( rank_of(to) != RANK_4
- || !square_is_empty(to)
- || !square_is_empty(from + DELTA_N))
+ || !square_empty(to)
+ || !square_empty(from + DELTA_N))
// rank, and both the destination square and the square between the
// source and destination squares must be empty.
if ( rank_of(to) != RANK_5
// rank, and both the destination square and the square between the
// source and destination squares must be empty.
if ( rank_of(to) != RANK_5
- || !square_is_empty(to)
- || !square_is_empty(from + DELTA_S))
+ || !square_empty(to)
+ || !square_empty(from + DELTA_S))
Key pawnKey, materialKey;
Value npMaterial[2];
int castleRights, rule50, pliesFromNull;
Key pawnKey, materialKey;
Value npMaterial[2];
int castleRights, rule50, pliesFromNull;
st->materialKey ^= zobrist[them][capture][pieceCount[them][capture]];
// Update incremental scores
st->materialKey ^= zobrist[them][capture][pieceCount[them][capture]];
// Update incremental scores
- st->value -= pst(make_piece(them, capture), capsq);
+ st->psqScore -= pieceSquareTable[make_piece(them, capture)][capsq];
// Reset rule 50 counter
st->rule50 = 0;
// Reset rule 50 counter
st->rule50 = 0;
^ zobrist[us][PAWN][pieceCount[us][PAWN]];
// Update incremental score
^ zobrist[us][PAWN][pieceCount[us][PAWN]];
// Update incremental score
- st->value += pst(make_piece(us, promotion), to)
- - pst(make_piece(us, PAWN), to);
+ st->psqScore += pieceSquareTable[make_piece(us, promotion)][to]
+ - pieceSquareTable[make_piece(us, PAWN)][to];
// Update material
st->npMaterial[us] += PieceValueMidgame[promotion];
// Update material
st->npMaterial[us] += PieceValueMidgame[promotion];
prefetch((char*)Threads[threadID].materialTable.entries[st->materialKey]);
// Update incremental scores
prefetch((char*)Threads[threadID].materialTable.entries[st->materialKey]);
// Update incremental scores
- st->value += pst_delta(piece, from, to);
+ st->psqScore += psq_delta(piece, from, to);
// Set capture piece
st->capturedType = capture;
// Set capture piece
st->capturedType = capture;
// Finish
sideToMove = ~sideToMove;
// Finish
sideToMove = ~sideToMove;
- st->value += (sideToMove == WHITE ? TempoValue : -TempoValue);
+ st->psqScore += (sideToMove == WHITE ? Tempo : -Tempo);
PieceType pt = type_of(piece);
PieceType capture = st->capturedType;
PieceType pt = type_of(piece);
PieceType capture = st->capturedType;
- assert(square_is_empty(from));
+ assert(square_empty(from));
assert(color_of(piece) == us);
assert(capture != KING);
assert(color_of(piece) == us);
assert(capture != KING);
st->capturedType = NO_PIECE_TYPE;
// Update incremental scores
st->capturedType = NO_PIECE_TYPE;
// Update incremental scores
- st->value += pst_delta(king, kfrom, kto);
- st->value += pst_delta(rook, rfrom, rto);
+ st->psqScore += psq_delta(king, kfrom, kto);
+ st->psqScore += psq_delta(rook, rfrom, rto);
// Update hash key
st->key ^= zobrist[us][KING][kfrom] ^ zobrist[us][KING][kto];
// Update hash key
st->key ^= zobrist[us][KING][kfrom] ^ zobrist[us][KING][kto];
// Finish
sideToMove = ~sideToMove;
// Finish
sideToMove = ~sideToMove;
- st->value += (sideToMove == WHITE ? TempoValue : -TempoValue);
+ st->psqScore += (sideToMove == WHITE ? Tempo : -Tempo);
}
else
// Undo: point our state pointer back to the previous state
}
else
// Undo: point our state pointer back to the previous state
dst->key = src->key;
dst->epSquare = src->epSquare;
dst->key = src->key;
dst->epSquare = src->epSquare;
- dst->value = src->value;
+ dst->psqScore = src->psqScore;
dst->rule50 = src->rule50;
dst->pliesFromNull = src->pliesFromNull;
dst->rule50 = src->rule50;
dst->pliesFromNull = src->pliesFromNull;
st->epSquare = SQ_NONE;
st->rule50++;
st->pliesFromNull = 0;
st->epSquare = SQ_NONE;
st->rule50++;
st->pliesFromNull = 0;
- st->value += (sideToMove == WHITE) ? TempoValue : -TempoValue;
+ st->psqScore += (sideToMove == WHITE ? Tempo : -Tempo);
Key result = zobCastle[st->castleRights];
for (Square s = SQ_A1; s <= SQ_H8; s++)
Key result = zobCastle[st->castleRights];
for (Square s = SQ_A1; s <= SQ_H8; s++)
- if (!square_is_empty(s))
result ^= zobrist[color_of(piece_on(s))][type_of(piece_on(s))][s];
if (ep_square() != SQ_NONE)
result ^= zobrist[color_of(piece_on(s))][type_of(piece_on(s))][s];
if (ep_square() != SQ_NONE)
-/// Position::compute_value() compute the incremental scores for the middle
+/// Position::compute_psq_score() computes the incremental scores for the middle
/// game and the endgame. These functions are used to initialize the incremental
/// scores when a new position is set up, and to verify that the scores are correctly
/// updated by do_move and undo_move when the program is running in debug mode.
/// game and the endgame. These functions are used to initialize the incremental
/// scores when a new position is set up, and to verify that the scores are correctly
/// updated by do_move and undo_move when the program is running in debug mode.
-Score Position::compute_value() const {
+Score Position::compute_psq_score() const {
Bitboard b;
Score result = SCORE_ZERO;
Bitboard b;
Score result = SCORE_ZERO;
{
b = pieces(pt, c);
while (b)
{
b = pieces(pt, c);
while (b)
- result += pst(make_piece(c, pt), pop_1st_bit(&b));
+ result += pieceSquareTable[make_piece(c, pt)][pop_1st_bit(&b)];
- result += (sideToMove == WHITE ? TempoValue / 2 : -TempoValue / 2);
+ result += (sideToMove == WHITE ? Tempo / 2 : -Tempo / 2);
-/// Position::flip_me() flips position with the white and black sides reversed. This
+/// Position::flip() flips position with the white and black sides reversed. This
/// is only useful for debugging especially for finding evaluation symmetry bugs.
/// is only useful for debugging especially for finding evaluation symmetry bugs.
-void Position::flip_me() {
// Make a copy of current position before to start changing
const Position pos(*this, threadID);
clear();
// Make a copy of current position before to start changing
const Position pos(*this, threadID);
clear();
- threadID = pos.thread();
+ threadID = pos.this_thread();
// Board
for (Square s = SQ_A1; s <= SQ_H8; s++)
// Board
for (Square s = SQ_A1; s <= SQ_H8; s++)
- if (!pos.square_is_empty(s))
+ if (!pos.square_empty(s))
put_piece(Piece(pos.piece_on(s) ^ 8), ~s);
// Side to move
put_piece(Piece(pos.piece_on(s) ^ 8), ~s);
// Side to move
st->materialKey = compute_material_key();
// Incremental scores
st->materialKey = compute_material_key();
// Incremental scores
- st->value = compute_value();
+ st->psqScore = compute_psq_score();
// Material
st->npMaterial[WHITE] = compute_non_pawn_material(WHITE);
// Material
st->npMaterial[WHITE] = compute_non_pawn_material(WHITE);
// Incremental eval OK?
if (failedStep) (*failedStep)++;
// Incremental eval OK?
if (failedStep) (*failedStep)++;
- if (debugIncrementalEval && st->value != compute_value())
+ if (debugIncrementalEval && st->psqScore != compute_psq_score())
return false;
// Non-pawn material OK?
return false;
// Non-pawn material OK?
Key pawnKey, materialKey;
Value npMaterial[2];
int castleRights, rule50, pliesFromNull;
Key pawnKey, materialKey;
Value npMaterial[2];
int castleRights, rule50, pliesFromNull;
Square epSquare;
Key key;
Square epSquare;
Key key;
const std::string to_fen() const;
void print(Move m = MOVE_NONE) const;
const std::string to_fen() const;
void print(Move m = MOVE_NONE) const;
- // The piece on a given square
- Piece piece_on(Square s) const;
- Piece piece_moved(Move m) const;
- bool square_is_empty(Square s) const;
-
- // Side to move
- Color side_to_move() const;
-
- // Bitboard representation of the position
+ // Position representation
Bitboard pieces() const;
Bitboard pieces(Color c) const;
Bitboard pieces(PieceType pt) const;
Bitboard pieces(PieceType pt, Color c) const;
Bitboard pieces(PieceType pt1, PieceType pt2) const;
Bitboard pieces(PieceType pt1, PieceType pt2, Color c) const;
Bitboard pieces() const;
Bitboard pieces(Color c) const;
Bitboard pieces(PieceType pt) const;
Bitboard pieces(PieceType pt, Color c) const;
Bitboard pieces(PieceType pt1, PieceType pt2) const;
Bitboard pieces(PieceType pt1, PieceType pt2, Color c) const;
-
- // Number of pieces of each color and type
- int piece_count(Color c, PieceType pt) const;
-
- // The en passant square
- Square ep_square() const;
-
- // Current king position for each color
+ Piece piece_on(Square s) const;
Square king_square(Color c) const;
Square king_square(Color c) const;
+ Square ep_square() const;
+ bool square_empty(Square s) const;
+ const Square* piece_list(Color c, PieceType pt) const;
+ int piece_count(Color c, PieceType pt) const;
bool can_castle(CastleRight f) const;
bool can_castle(Color c) const;
bool castle_impeded(CastleRight f) const;
Square castle_rook_square(CastleRight f) const;
bool can_castle(CastleRight f) const;
bool can_castle(Color c) const;
bool castle_impeded(CastleRight f) const;
Square castle_rook_square(CastleRight f) const;
- // Bitboards for pinned pieces and discovered check candidates
+ // Checking
+ bool in_check() const;
+ Bitboard checkers() const;
Bitboard discovered_check_candidates() const;
Bitboard pinned_pieces() const;
Bitboard discovered_check_candidates() const;
Bitboard pinned_pieces() const;
- // Checking pieces and under check information
- Bitboard checkers() const;
- bool in_check() const;
-
- // Piece lists
- const Square* piece_list(Color c, PieceType pt) const;
-
- // Information about attacks to or from a given square
+ // Attacks to/from a given square
Bitboard attackers_to(Square s) const;
Bitboard attackers_to(Square s, Bitboard occ) const;
Bitboard attacks_from(Piece p, Square s) const;
Bitboard attackers_to(Square s) const;
Bitboard attackers_to(Square s, Bitboard occ) const;
Bitboard attacks_from(Piece p, Square s) const;
bool is_capture(Move m) const;
bool is_capture_or_promotion(Move m) const;
bool is_passed_pawn_push(Move m) const;
bool is_capture(Move m) const;
bool is_capture_or_promotion(Move m) const;
bool is_passed_pawn_push(Move m) const;
-
- // Piece captured with previous moves
+ Piece piece_moved(Move m) const;
PieceType captured_piece_type() const;
PieceType captured_piece_type() const;
- // Information about pawns
bool pawn_is_passed(Color c, Square s) const;
bool pawn_is_passed(Color c, Square s) const;
+ bool pawn_on_7th(Color c) const;
+ bool opposite_bishops() const;
+ bool bishop_pair(Color c) const;
// Doing and undoing moves
void do_move(Move m, StateInfo& st);
// Doing and undoing moves
void do_move(Move m, StateInfo& st);
Key pawn_key() const;
Key material_key() const;
Key pawn_key() const;
Key material_key() const;
- // Incremental evaluation
- Score value() const;
+ // Incremental piece-square evaluation
+ Score psq_score() const;
+ Score psq_delta(Piece p, Square from, Square to) const;
Value non_pawn_material(Color c) const;
Value non_pawn_material(Color c) const;
- Score pst_delta(Piece piece, Square from, Square to) const;
// Other properties of the position
// Other properties of the position
- template<bool SkipRepetition> bool is_draw() const;
+ Color side_to_move() const;
int startpos_ply_counter() const;
int startpos_ply_counter() const;
- bool opposite_colored_bishops() const;
- bool both_color_bishops(Color c) const;
- bool has_pawn_on_7th(Color c) const;
bool is_chess960() const;
bool is_chess960() const;
+ int this_thread() const;
int64_t nodes_searched() const;
void set_nodes_searched(int64_t n);
int64_t nodes_searched() const;
void set_nodes_searched(int64_t n);
+ template<bool SkipRepetition> bool is_draw() const;
// Position consistency check, for debugging
bool pos_is_ok(int* failedStep = NULL) const;
// Position consistency check, for debugging
bool pos_is_ok(int* failedStep = NULL) const;
// Global initialization
static void init();
private:
// Global initialization
static void init();
private:
-
- // Initialization helper functions (used while setting up a position)
+ // Initialization helpers (used while setting up a position)
void clear();
void put_piece(Piece p, Square s);
void set_castle_right(Color c, Square rfrom);
void clear();
void put_piece(Piece p, Square s);
void set_castle_right(Color c, Square rfrom);
Key compute_material_key() const;
// Computing incremental evaluation scores and material counts
Key compute_material_key() const;
// Computing incremental evaluation scores and material counts
- Score pst(Piece p, Square s) const;
- Score compute_value() const;
+ Score compute_psq_score() const;
Value compute_non_pawn_material(Color c) const;
Value compute_non_pawn_material(Color c) const;
Piece board[64]; // [square]
Piece board[64]; // [square]
Bitboard byTypeBB[8]; // [pieceType]
Bitboard byColorBB[2]; // [color]
Bitboard byTypeBB[8]; // [pieceType]
Bitboard byColorBB[2]; // [color]
int pieceCount[2][8]; // [color][pieceType]
int pieceCount[2][8]; // [color][pieceType]
Square pieceList[2][8][16]; // [color][pieceType][index]
int index[64]; // [square]
Square pieceList[2][8][16]; // [color][pieceType][index]
int index[64]; // [square]
return board[from_sq(m)];
}
return board[from_sq(m)];
}
-inline bool Position::square_is_empty(Square s) const {
+inline bool Position::square_empty(Square s) const {
return board[s] == NO_PIECE;
}
return board[s] == NO_PIECE;
}
template<PieceType Pt>
inline Bitboard Position::attacks_from(Square s) const {
template<PieceType Pt>
inline Bitboard Position::attacks_from(Square s) const {
return Pt == BISHOP || Pt == ROOK ? attacks_bb<Pt>(s, pieces())
: Pt == QUEEN ? attacks_from<ROOK>(s) | attacks_from<BISHOP>(s)
: StepAttacksBB[Pt][s];
return Pt == BISHOP || Pt == ROOK ? attacks_bb<Pt>(s, pieces())
: Pt == QUEEN ? attacks_from<ROOK>(s) | attacks_from<BISHOP>(s)
: StepAttacksBB[Pt][s];
return st->materialKey;
}
return st->materialKey;
}
-inline Score Position::pst(Piece p, Square s) const {
- return pieceSquareTable[p][s];
-}
-
-inline Score Position::pst_delta(Piece piece, Square from, Square to) const {
- return pieceSquareTable[piece][to] - pieceSquareTable[piece][from];
+inline Score Position::psq_delta(Piece p, Square from, Square to) const {
+ return pieceSquareTable[p][to] - pieceSquareTable[p][from];
-inline Score Position::value() const {
- return st->value;
+inline Score Position::psq_score() const {
+ return st->psqScore;
}
inline Value Position::non_pawn_material(Color c) const {
}
inline Value Position::non_pawn_material(Color c) const {
inline bool Position::is_passed_pawn_push(Move m) const {
inline bool Position::is_passed_pawn_push(Move m) const {
- return board[from_sq(m)] == make_piece(sideToMove, PAWN)
+ return type_of(piece_moved(m)) == PAWN
&& pawn_is_passed(sideToMove, to_sq(m));
}
&& pawn_is_passed(sideToMove, to_sq(m));
}
return startPosPly + st->pliesFromNull; // HACK
}
return startPosPly + st->pliesFromNull; // HACK
}
-inline bool Position::opposite_colored_bishops() const {
+inline bool Position::opposite_bishops() const {
return pieceCount[WHITE][BISHOP] == 1
&& pieceCount[BLACK][BISHOP] == 1
&& opposite_colors(pieceList[WHITE][BISHOP][0], pieceList[BLACK][BISHOP][0]);
}
return pieceCount[WHITE][BISHOP] == 1
&& pieceCount[BLACK][BISHOP] == 1
&& opposite_colors(pieceList[WHITE][BISHOP][0], pieceList[BLACK][BISHOP][0]);
}
-inline bool Position::both_color_bishops(Color c) const {
- // Assumes that there are only two bishops
- return pieceCount[c][BISHOP] >= 2 &&
- opposite_colors(pieceList[c][BISHOP][0], pieceList[c][BISHOP][1]);
+inline bool Position::bishop_pair(Color c) const {
+
+ return pieceCount[c][BISHOP] >= 2
+ && opposite_colors(pieceList[c][BISHOP][0], pieceList[c][BISHOP][1]);
-inline bool Position::has_pawn_on_7th(Color c) const {
+inline bool Position::pawn_on_7th(Color c) const {
return pieces(PAWN, c) & rank_bb(relative_rank(c, RANK_7));
}
return pieces(PAWN, c) & rank_bb(relative_rank(c, RANK_7));
}
inline bool Position::is_capture_or_promotion(Move m) const {
assert(is_ok(m));
inline bool Position::is_capture_or_promotion(Move m) const {
assert(is_ok(m));
- return is_special(m) ? !is_castle(m) : !square_is_empty(to_sq(m));
+ return is_special(m) ? !is_castle(m) : !square_empty(to_sq(m));
}
inline bool Position::is_capture(Move m) const {
// Note that castle is coded as "king captures the rook"
assert(is_ok(m));
}
inline bool Position::is_capture(Move m) const {
// Note that castle is coded as "king captures the rook"
assert(is_ok(m));
- return (!square_is_empty(to_sq(m)) && !is_castle(m)) || is_enpassant(m);
+ return (!square_empty(to_sq(m)) && !is_castle(m)) || is_enpassant(m);
}
inline PieceType Position::captured_piece_type() const {
return st->capturedType;
}
}
inline PieceType Position::captured_piece_type() const {
return st->capturedType;
}
-inline int Position::thread() const {
+inline int Position::this_thread() const {
// but if we are pondering or in infinite search, we shouldn't print the best
// move before we are told to do so.
if (!Signals.stop && (Limits.ponder || Limits.infinite))
// but if we are pondering or in infinite search, we shouldn't print the best
// move before we are told to do so.
if (!Signals.stop && (Limits.ponder || Limits.infinite))
- Threads[pos.thread()].wait_for_stop_or_ponderhit();
+ Threads[pos.this_thread()].wait_for_stop_or_ponderhit();
// Best move could be MOVE_NONE when searching on a stalemate position
cout << "bestmove " << move_to_uci(RootMoves[0].pv[0], Chess960)
// Best move could be MOVE_NONE when searching on a stalemate position
cout << "bestmove " << move_to_uci(RootMoves[0].pv[0], Chess960)
assert(alpha >= -VALUE_INFINITE && alpha < beta && beta <= VALUE_INFINITE);
assert((alpha == beta - 1) || PvNode);
assert(depth > DEPTH_ZERO);
assert(alpha >= -VALUE_INFINITE && alpha < beta && beta <= VALUE_INFINITE);
assert((alpha == beta - 1) || PvNode);
assert(depth > DEPTH_ZERO);
- assert(pos.thread() >= 0 && pos.thread() < Threads.size());
+ assert(pos.this_thread() >= 0 && pos.this_thread() < Threads.size());
Move movesSearched[MAX_MOVES];
StateInfo st;
Move movesSearched[MAX_MOVES];
StateInfo st;
bool isPvMove, inCheck, singularExtensionNode, givesCheck;
bool captureOrPromotion, dangerous, doFullDepthSearch;
int moveCount = 0, playedMoveCount = 0;
bool isPvMove, inCheck, singularExtensionNode, givesCheck;
bool captureOrPromotion, dangerous, doFullDepthSearch;
int moveCount = 0, playedMoveCount = 0;
- Thread& thread = Threads[pos.thread()];
+ Thread& thread = Threads[pos.this_thread()];
SplitPoint* sp = NULL;
refinedValue = bestValue = value = -VALUE_INFINITE;
SplitPoint* sp = NULL;
refinedValue = bestValue = value = -VALUE_INFINITE;
&& refinedValue + razor_margin(depth) < beta
&& ttMove == MOVE_NONE
&& abs(beta) < VALUE_MATE_IN_MAX_PLY
&& refinedValue + razor_margin(depth) < beta
&& ttMove == MOVE_NONE
&& abs(beta) < VALUE_MATE_IN_MAX_PLY
- && !pos.has_pawn_on_7th(pos.side_to_move()))
+ && !pos.pawn_on_7th(pos.side_to_move()))
{
Value rbeta = beta - razor_margin(depth);
Value v = qsearch<NonPV>(pos, ss, rbeta-1, rbeta, DEPTH_ZERO);
{
Value rbeta = beta - razor_margin(depth);
Value v = qsearch<NonPV>(pos, ss, rbeta-1, rbeta, DEPTH_ZERO);
{
Signals.firstRootMove = (moveCount == 1);
{
Signals.firstRootMove = (moveCount == 1);
- if (pos.thread() == 0 && SearchTime.elapsed() > 2000)
+ if (pos.this_thread() == 0 && SearchTime.elapsed() > 2000)
cout << "info depth " << depth / ONE_PLY
<< " currmove " << move_to_uci(move, Chess960)
<< " currmovenumber " << moveCount + PVIdx << endl;
cout << "info depth " << depth / ONE_PLY
<< " currmove " << move_to_uci(move, Chess960)
<< " currmovenumber " << moveCount + PVIdx << endl;
if ( !SpNode
&& depth >= Threads.min_split_depth()
&& bestValue < beta
if ( !SpNode
&& depth >= Threads.min_split_depth()
&& bestValue < beta
- && Threads.available_slave_exists(pos.thread())
+ && Threads.available_slave_exists(pos.this_thread())
&& !Signals.stop
&& !thread.cutoff_occurred())
bestValue = Threads.split<FakeSplit>(pos, ss, alpha, beta, bestValue, &bestMove,
&& !Signals.stop
&& !thread.cutoff_occurred())
bestValue = Threads.split<FakeSplit>(pos, ss, alpha, beta, bestValue, &bestMove,
assert(alpha >= -VALUE_INFINITE && alpha < beta && beta <= VALUE_INFINITE);
assert((alpha == beta - 1) || PvNode);
assert(depth <= DEPTH_ZERO);
assert(alpha >= -VALUE_INFINITE && alpha < beta && beta <= VALUE_INFINITE);
assert((alpha == beta - 1) || PvNode);
assert(depth <= DEPTH_ZERO);
- assert(pos.thread() >= 0 && pos.thread() < Threads.size());
+ assert(pos.this_thread() >= 0 && pos.this_thread() < Threads.size());
StateInfo st;
Move ttMove, move, bestMove;
StateInfo st;
Move ttMove, move, bestMove;
assert(beta <= VALUE_INFINITE);
assert(depth > DEPTH_ZERO);
assert(beta <= VALUE_INFINITE);
assert(depth > DEPTH_ZERO);
- int master = pos.thread();
+ int master = pos.this_thread();
Thread& masterThread = *threads[master];
if (masterThread.splitPointsCnt >= MAX_SPLITPOINTS_PER_THREAD)
Thread& masterThread = *threads[master];
if (masterThread.splitPointsCnt >= MAX_SPLITPOINTS_PER_THREAD)
pos.print();
else if (token == "flip")
pos.print();
else if (token == "flip")
else if (token == "eval")
cout << Eval::trace(pos) << endl;
else if (token == "eval")
cout << Eval::trace(pos) << endl;