summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
e8ffca3)
I've gone through the RENAME/REFORMATTING thread and changed everything I could find, plus a few more. With this, let's close the previous issue and open another.
No functional change.
Michel Van den Bergh (vdbergh)
Miguel Lahoz (miguel-l)
Mikael Bäckman (mbootsector)
Michel Van den Bergh (vdbergh)
Miguel Lahoz (miguel-l)
Mikael Bäckman (mbootsector)
-Mike Whiteley (protonspring)
+Michael Whiteley (protonspring)
Miroslav Fontán (Hexik)
Moez Jellouli (MJZ1977)
Mohammed Li (tthsqe12)
Miroslav Fontán (Hexik)
Moez Jellouli (MJZ1977)
Mohammed Li (tthsqe12)
{
File kf = file_of(pos.square<KING>(Us));
if ((kf < FILE_E) == (file_of(s) < kf))
{
File kf = file_of(pos.square<KING>(Us));
if ((kf < FILE_E) == (file_of(s) < kf))
- score -= (TrappedRook - make_score(mob * 22, 0)) * (1 + !pos.can_castle(Us));
+ score -= (TrappedRook - make_score(mob * 22, 0)) * (1 + !pos.castling_rights(Us));
Score score = SCORE_ZERO;
// Non-pawn enemies
Score score = SCORE_ZERO;
// Non-pawn enemies
- nonPawnEnemies = pos.pieces(Them) ^ pos.pieces(Them, PAWN);
+ nonPawnEnemies = pos.pieces(Them) & ~pos.pieces(Them, PAWN);
// Squares strongly protected by the enemy, either because they defend the
// square with a pawn, or because they defend the square twice and we don't.
// Squares strongly protected by the enemy, either because they defend the
// square with a pawn, or because they defend the square twice and we don't.
Key key;
const EndgameBase<Value>* evaluationFunction;
const EndgameBase<ScaleFactor>* scalingFunction[COLOR_NB]; // Could be one for each
Key key;
const EndgameBase<Value>* evaluationFunction;
const EndgameBase<ScaleFactor>* scalingFunction[COLOR_NB]; // Could be one for each
- // side (e.g. KPKP, KBPsKs)
+ // side (e.g. KPKP, KBPsK)
int16_t value;
uint8_t factor[COLOR_NB];
Phase gamePhase;
int16_t value;
uint8_t factor[COLOR_NB];
Phase gamePhase;
*moveList++ = make_move(ksq, pop_lsb(&b));
}
*moveList++ = make_move(ksq, pop_lsb(&b));
}
- if (Type != CAPTURES && Type != EVASIONS && pos.can_castle(Us))
+ if (Type != CAPTURES && Type != EVASIONS && pos.castling_rights(Us))
{
if (pos.is_chess960())
{
{
if (pos.is_chess960())
{
constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
constexpr Direction Up = (Us == WHITE ? NORTH : SOUTH);
constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
constexpr Direction Up = (Us == WHITE ? NORTH : SOUTH);
- Bitboard b, neighbours, stoppers, doubled, supported, phalanx;
+ Bitboard b, neighbours, stoppers, doubled, support, phalanx;
Bitboard lever, leverPush;
Square s;
bool opposed, backward;
Bitboard lever, leverPush;
Square s;
bool opposed, backward;
doubled = ourPawns & (s - Up);
neighbours = ourPawns & adjacent_files_bb(f);
phalanx = neighbours & rank_bb(s);
doubled = ourPawns & (s - Up);
neighbours = ourPawns & adjacent_files_bb(f);
phalanx = neighbours & rank_bb(s);
- supported = neighbours & rank_bb(s - Up);
+ support = neighbours & rank_bb(s - Up);
// A pawn is backward when it is behind all pawns of the same color
// on the adjacent files and cannot be safely advanced.
// A pawn is backward when it is behind all pawns of the same color
// on the adjacent files and cannot be safely advanced.
// which could become passed after one or two pawn pushes when are
// not attacked more times than defended.
if ( !(stoppers ^ lever ^ leverPush)
// which could become passed after one or two pawn pushes when are
// not attacked more times than defended.
if ( !(stoppers ^ lever ^ leverPush)
- && popcount(supported) >= popcount(lever) - 1
+ && popcount(support) >= popcount(lever) - 1
&& popcount(phalanx) >= popcount(leverPush))
e->passedPawns[Us] |= s;
else if ( stoppers == SquareBB[s + Up]
&& relative_rank(Us, s) >= RANK_5)
{
&& popcount(phalanx) >= popcount(leverPush))
e->passedPawns[Us] |= s;
else if ( stoppers == SquareBB[s + Up]
&& relative_rank(Us, s) >= RANK_5)
{
- b = shift<Up>(supported) & ~theirPawns;
+ b = shift<Up>(support) & ~theirPawns;
while (b)
if (!more_than_one(theirPawns & PawnAttacks[Us][pop_lsb(&b)]))
e->passedPawns[Us] |= s;
}
// Score this pawn
while (b)
if (!more_than_one(theirPawns & PawnAttacks[Us][pop_lsb(&b)]))
e->passedPawns[Us] |= s;
}
// Score this pawn
- if (supported | phalanx)
- score += Connected[opposed][bool(phalanx)][popcount(supported)][relative_rank(Us, s)];
+ if (support | phalanx)
+ score += Connected[opposed][bool(phalanx)][popcount(support)][relative_rank(Us, s)];
else if (!neighbours)
score -= Isolated, e->weakUnopposed[Us] += !opposed;
else if (!neighbours)
score -= Isolated, e->weakUnopposed[Us] += !opposed;
else if (backward)
score -= Backward, e->weakUnopposed[Us] += !opposed;
else if (backward)
score -= Backward, e->weakUnopposed[Us] += !opposed;
- if (doubled && !supported)
+ if (doubled && !support)
for (File f = File(center - 1); f <= File(center + 1); ++f)
{
b = ourPawns & file_bb(f);
for (File f = File(center - 1); f <= File(center + 1); ++f)
{
b = ourPawns & file_bb(f);
- int ourRank = b ? relative_rank(Us, backmost_sq(Us, b)) : 0;
+ Rank ourRank = b ? relative_rank(Us, backmost_sq(Us, b)) : RANK_1;
b = theirPawns & file_bb(f);
b = theirPawns & file_bb(f);
- int theirRank = b ? relative_rank(Us, frontmost_sq(Them, b)) : 0;
+ Rank theirRank = b ? relative_rank(Us, frontmost_sq(Them, b)) : RANK_1;
int d = std::min(f, ~f);
safety += ShelterStrength[d][ourRank];
int d = std::min(f, ~f);
safety += ShelterStrength[d][ourRank];
Square ksq = pos.square<KING>(Us);
kingSquares[Us] = ksq;
Square ksq = pos.square<KING>(Us);
kingSquares[Us] = ksq;
- castlingRights[Us] = pos.can_castle(Us);
+ castlingRights[Us] = pos.castling_rights(Us);
int minKingPawnDistance = 0;
Bitboard pawns = pos.pieces(Us, PAWN);
int minKingPawnDistance = 0;
Bitboard pawns = pos.pieces(Us, PAWN);
template<Color Us>
Score king_safety(const Position& pos) {
template<Color Us>
Score king_safety(const Position& pos) {
- return kingSquares[Us] == pos.square<KING>(Us) && castlingRights[Us] == pos.can_castle(Us)
+ return kingSquares[Us] == pos.square<KING>(Us) && castlingRights[Us] == pos.castling_rights(Us)
? kingSafety[Us] : (kingSafety[Us] = do_king_safety<Us>(pos));
}
? kingSafety[Us] : (kingSafety[Us] = do_king_safety<Us>(pos));
}
if (can_castle(BLACK_OOO))
ss << (chess960 ? char('a' + file_of(castling_rook_square(BLACK | QUEEN_SIDE))) : 'q');
if (can_castle(BLACK_OOO))
ss << (chess960 ? char('a' + file_of(castling_rook_square(BLACK | QUEEN_SIDE))) : 'q');
- if (!can_castle(WHITE) && !can_castle(BLACK))
+ if (!can_castle(ANY_CASTLING))
ss << '-';
ss << (ep_square() == SQ_NONE ? " - " : " " + UCI::square(ep_square()) + " ")
ss << '-';
ss << (ep_square() == SQ_NONE ? " - " : " " + UCI::square(ep_square()) + " ")
template<PieceType Pt> Square square(Color c) const;
// Castling
template<PieceType Pt> Square square(Color c) const;
// Castling
- int can_castle(Color c) const;
- int can_castle(CastlingRight cr) const;
+ int castling_rights(Color c) const;
+ bool can_castle(CastlingRight cr) const;
bool castling_impeded(CastlingRight cr) const;
Square castling_rook_square(CastlingRight cr) const;
bool castling_impeded(CastlingRight cr) const;
Square castling_rook_square(CastlingRight cr) const;
-inline int Position::can_castle(CastlingRight cr) const {
+inline bool Position::can_castle(CastlingRight cr) const {
return st->castlingRights & cr;
}
return st->castlingRights & cr;
}
-inline int Position::can_castle(Color c) const {
+inline int Position::castling_rights(Color c) const {
return st->castlingRights & ((WHITE_OO | WHITE_OOO) << (2 * c));
}
return st->castlingRights & ((WHITE_OO | WHITE_OOO) << (2 * c));
}
&& depth >= 5 * ONE_PLY
&& abs(beta) < VALUE_MATE_IN_MAX_PLY)
{
&& depth >= 5 * ONE_PLY
&& abs(beta) < VALUE_MATE_IN_MAX_PLY)
{
- Value rbeta = std::min(beta + 216 - 48 * improving, VALUE_INFINITE);
- MovePicker mp(pos, ttMove, rbeta - ss->staticEval, &thisThread->captureHistory);
+ Value raisedBeta = std::min(beta + 216 - 48 * improving, VALUE_INFINITE);
+ MovePicker mp(pos, ttMove, raisedBeta - ss->staticEval, &thisThread->captureHistory);
int probCutCount = 0;
while ( (move = mp.next_move()) != MOVE_NONE
int probCutCount = 0;
while ( (move = mp.next_move()) != MOVE_NONE
pos.do_move(move, st);
// Perform a preliminary qsearch to verify that the move holds
pos.do_move(move, st);
// Perform a preliminary qsearch to verify that the move holds
- value = -qsearch<NonPV>(pos, ss+1, -rbeta, -rbeta+1);
+ value = -qsearch<NonPV>(pos, ss+1, -raisedBeta, -raisedBeta+1);
// If the qsearch held perform the regular search
// If the qsearch held perform the regular search
- if (value >= rbeta)
- value = -search<NonPV>(pos, ss+1, -rbeta, -rbeta+1, depth - 4 * ONE_PLY, !cutNode);
+ if (value >= raisedBeta)
+ value = -search<NonPV>(pos, ss+1, -raisedBeta, -raisedBeta+1, depth - 4 * ONE_PLY, !cutNode);
+ if (value >= raisedBeta)
if ( depth >= 8 * ONE_PLY
&& move == ttMove
&& !rootNode
if ( depth >= 8 * ONE_PLY
&& move == ttMove
&& !rootNode
- && !excludedMove // Recursive singular search is not allowed
+ && !excludedMove // Avoid recursive singular search
&& ttValue != VALUE_NONE
&& (tte->bound() & BOUND_LOWER)
&& tte->depth() >= depth - 3 * ONE_PLY
&& pos.legal(move))
{
&& ttValue != VALUE_NONE
&& (tte->bound() & BOUND_LOWER)
&& tte->depth() >= depth - 3 * ONE_PLY
&& pos.legal(move))
{
- Value rBeta = std::max(ttValue - 2 * depth / ONE_PLY, -VALUE_MATE);
+ Value reducedBeta = std::max(ttValue - 2 * depth / ONE_PLY, -VALUE_MATE);
- value = search<NonPV>(pos, ss, rBeta - 1, rBeta, depth / 2, cutNode);
+ value = search<NonPV>(pos, ss, reducedBeta - 1, reducedBeta, depth / 2, cutNode);
ss->excludedMove = MOVE_NONE;
ss->excludedMove = MOVE_NONE;
+ if (value < reducedBeta)
extension = ONE_PLY;
}
else if ( givesCheck // Check extension (~2 Elo)
extension = ONE_PLY;
}
else if ( givesCheck // Check extension (~2 Elo)
update_capture_stats(pos, bestMove, capturesSearched, captureCount, stat_bonus(depth + ONE_PLY));
// Extra penalty for a quiet TT or main killer move in previous ply when it gets refuted
update_capture_stats(pos, bestMove, capturesSearched, captureCount, stat_bonus(depth + ONE_PLY));
// Extra penalty for a quiet TT or main killer move in previous ply when it gets refuted
- if ( (ss-1)->moveCount == 1
- || ((ss-1)->currentMove == (ss-1)->killers[0] && (ss-1)->killers[0]))
- if (!pos.captured_piece())
+ if ( (ss-1)->moveCount == 1
+ || ((ss-1)->currentMove == (ss-1)->killers[0] && (ss-1)->killers[0]))
+ if (!pos.captured_piece())
update_continuation_histories(ss-1, pos.piece_on(prevSq), prevSq, -stat_bonus(depth + ONE_PLY));
}
update_continuation_histories(ss-1, pos.piece_on(prevSq), prevSq, -stat_bonus(depth + ONE_PLY));
}
- // Use 'aquire' to avoid a thread reads 'ready' == true while another is
- // still working, this could happen due to compiler reordering.
+ // Use 'acquire' to avoid a thread reading 'ready' == true while
+ // another is still working. (compiler reordering may cause this).
if (e.ready.load(std::memory_order_acquire))
if (e.ready.load(std::memory_order_acquire))
- return e.baseAddress; // Could be nullptr if file does not exsist
+ return e.baseAddress; // Could be nullptr if file does not exist
std::unique_lock<Mutex> lk(mutex);
std::unique_lock<Mutex> lk(mutex);
}
/// ThreadPool::set() creates/destroys threads to match the requested number.
}
/// ThreadPool::set() creates/destroys threads to match the requested number.
-/// Created and launched threads will go immediately to sleep in idle_loop.
+/// Created and launched threads will immediately go to sleep in idle_loop.
/// Upon resizing, threads are recreated to allow for binding if necessary.
void ThreadPool::set(size_t requested) {
/// Upon resizing, threads are recreated to allow for binding if necessary.
void ThreadPool::set(size_t requested) {