summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
ec2002c)
closes https://github.com/official-stockfish/Stockfish/pull/2567
No functional change.
/// pop_lsb() finds and clears the least significant bit in a non-zero bitboard
inline Square pop_lsb(Bitboard* b) {
/// pop_lsb() finds and clears the least significant bit in a non-zero bitboard
inline Square pop_lsb(Bitboard* b) {
const Square s = lsb(*b);
*b &= *b - 1;
return s;
}
const Square s = lsb(*b);
*b &= *b - 1;
return s;
}
-/// frontmost_sq() returns the most advanced square for the given color
+/// frontmost_sq() returns the most advanced square for the given color,
+/// requires a non-zero bitboard.
inline Square frontmost_sq(Color c, Bitboard b) {
inline Square frontmost_sq(Color c, Bitboard b) {
return c == WHITE ? msb(b) : lsb(b);
}
return c == WHITE ? msb(b) : lsb(b);
}
#include "endgame.h"
#include "movegen.h"
#include "endgame.h"
#include "movegen.h"
namespace {
// Used to drive the king towards the edge of the board
namespace {
// Used to drive the king towards the edge of the board
// No assertions about the material of weakSide, because we want draws to
// be detected even when the weaker side has some pawns.
// No assertions about the material of weakSide, because we want draws to
// be detected even when the weaker side has some pawns.
- Bitboard strongpawns = pos.pieces(strongSide, PAWN);
- Bitboard allpawns = pos.pieces(PAWN);
+ Bitboard strongPawns = pos.pieces(strongSide, PAWN);
+ Bitboard allPawns = pos.pieces(PAWN);
// All strongSide pawns are on a single rook file?
// All strongSide pawns are on a single rook file?
- if (!(strongpawns & ~FileABB) || !(strongpawns & ~FileHBB))
+ if (!(strongPawns & ~FileABB) || !(strongPawns & ~FileHBB))
{
Square bishopSq = pos.square<BISHOP>(strongSide);
{
Square bishopSq = pos.square<BISHOP>(strongSide);
- Square queeningSq = relative_square(strongSide, make_square(file_of(lsb(strongpawns)), RANK_8));
- Square weakkingSq = pos.square<KING>(weakSide);
+ Square queeningSq = relative_square(strongSide, make_square(file_of(lsb(strongPawns)), RANK_8));
+ Square weakKingSq = pos.square<KING>(weakSide);
if ( opposite_colors(queeningSq, bishopSq)
if ( opposite_colors(queeningSq, bishopSq)
- && distance(queeningSq, weakkingSq) <= 1)
+ && distance(queeningSq, weakKingSq) <= 1)
return SCALE_FACTOR_DRAW;
}
// If all the pawns are on the same B or G file, then it's potentially a draw
return SCALE_FACTOR_DRAW;
}
// If all the pawns are on the same B or G file, then it's potentially a draw
- if ((!(allpawns & ~FileBBB) || !(allpawns & ~FileGBB))
+ if ((!(allPawns & ~FileBBB) || !(allPawns & ~FileGBB))
&& pos.non_pawn_material(weakSide) == 0
&& pos.count<PAWN>(weakSide) >= 1)
{
&& pos.non_pawn_material(weakSide) == 0
&& pos.count<PAWN>(weakSide) >= 1)
{
// There's potential for a draw if our pawn is blocked on the 7th rank,
// the bishop cannot attack it or they only have one pawn left
if ( relative_rank(strongSide, weakPawnSq) == RANK_7
// There's potential for a draw if our pawn is blocked on the 7th rank,
// the bishop cannot attack it or they only have one pawn left
if ( relative_rank(strongSide, weakPawnSq) == RANK_7
- && (strongpawns & (weakPawnSq + pawn_push(weakSide)))
- && (opposite_colors(bishopSq, weakPawnSq) || !more_than_one(strongpawns)))
+ && (strongPawns & (weakPawnSq + pawn_push(weakSide)))
+ && (opposite_colors(bishopSq, weakPawnSq) || !more_than_one(strongPawns)))
{
int strongKingDist = distance(weakPawnSq, strongKingSq);
int weakKingDist = distance(weakPawnSq, weakKingSq);
{
int strongKingDist = distance(weakPawnSq, strongKingSq);
int weakKingDist = distance(weakPawnSq, weakKingSq);
Square ksq = pos.square<KING>(weakSide);
Bitboard pawns = pos.pieces(strongSide, PAWN);
Square ksq = pos.square<KING>(weakSide);
Bitboard pawns = pos.pieces(strongSide, PAWN);
- // If all pawns are ahead of the king, on a single rook file and
- // the king is within one file of the pawns, it's a draw.
- if ( !(pawns & ~forward_ranks_bb(weakSide, ksq))
- && !((pawns & ~FileABB) && (pawns & ~FileHBB))
- && distance<File>(ksq, lsb(pawns)) <= 1)
+ // If all pawns are ahead of the king on a single rook file, it's a draw.
+ if (!((pawns & ~FileABB) || (pawns & ~FileHBB)) &&
+ !(pawns & ~passed_pawn_span(weakSide, ksq)))
return SCALE_FACTOR_DRAW;
return SCALE_FACTOR_NONE;
return SCALE_FACTOR_DRAW;
return SCALE_FACTOR_NONE;
Square weakKingSq = pos.square<KING>(weakSide);
// Case 1: Defending king blocks the pawn, and cannot be driven away
Square weakKingSq = pos.square<KING>(weakSide);
// Case 1: Defending king blocks the pawn, and cannot be driven away
- if ( file_of(weakKingSq) == file_of(pawnSq)
- && relative_rank(strongSide, pawnSq) < relative_rank(strongSide, weakKingSq)
+ if ( (forward_file_bb(strongSide, pawnSq) & weakKingSq)
&& ( opposite_colors(weakKingSq, strongBishopSq)
|| relative_rank(strongSide, weakKingSq) <= RANK_6))
return SCALE_FACTOR_DRAW;
&& ( opposite_colors(weakKingSq, strongBishopSq)
|| relative_rank(strongSide, weakKingSq) <= RANK_6))
return SCALE_FACTOR_DRAW;
// Return a draw score if a position repeats once earlier but strictly
// after the root, or repeats twice before or at the root.
// Return a draw score if a position repeats once earlier but strictly
// after the root, or repeats twice before or at the root.
- if (st->repetition && st->repetition < ply)
- return true;
-
- return false;
+ return st->repetition && st->repetition < ply;
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, d, true);
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, d, true);
- doFullDepthSearch = (value > alpha && d != newDepth), didLMR = true;
+ doFullDepthSearch = value > alpha && d != newDepth;
+
+ didLMR = true;
- doFullDepthSearch = !PvNode || moveCount > 1, didLMR = false;
+ {
+ doFullDepthSearch = !PvNode || moveCount > 1;
+
+ didLMR = false;
+ }
// Step 17. Full depth search when LMR is skipped or fails high
if (doFullDepthSearch)
// Step 17. Full depth search when LMR is skipped or fails high
if (doFullDepthSearch)
if (!off_A1H8(squares[i]))
continue;
if (!off_A1H8(squares[i]))
continue;
- if (off_A1H8(squares[i]) > 0) // A1-H8 diagonal flip: SQ_A3 -> SQ_C3
+ if (off_A1H8(squares[i]) > 0) // A1-H8 diagonal flip: SQ_A3 -> SQ_C1
for (int j = i; j < size; ++j)
squares[j] = Square(((squares[j] >> 3) | (squares[j] << 3)) & 63);
break;
for (int j = i; j < size; ++j)
squares[j] = Square(((squares[j] >> 3) | (squares[j] << 3)) & 63);
break;
Value value() const { return (Value)value16; }
Value eval() const { return (Value)eval16; }
Depth depth() const { return (Depth)depth8 + DEPTH_OFFSET; }
Value value() const { return (Value)value16; }
Value eval() const { return (Value)eval16; }
Depth depth() const { return (Depth)depth8 + DEPTH_OFFSET; }
- bool is_pv() const { return (bool)(genBound8 & 0x4); }
+ bool is_pv() const { return (bool)(genBound8 & 0x4); }
Bound bound() const { return (Bound)(genBound8 & 0x3); }
void save(Key k, Value v, bool pv, Bound b, Depth d, Move m, Value ev);
Bound bound() const { return (Bound)(genBound8 & 0x3); }
void save(Key k, Value v, bool pv, Bound b, Depth d, Move m, Value ev);
DEPTH_QS_RECAPTURES = -5,
DEPTH_NONE = -6,
DEPTH_QS_RECAPTURES = -5,
DEPTH_NONE = -6,
- DEPTH_OFFSET = DEPTH_NONE,
+ DEPTH_OFFSET = DEPTH_NONE
- if (abs(v) < VALUE_MATE - MAX_PLY)
+ if (abs(v) < VALUE_MATE_IN_MAX_PLY)
ss << "cp " << v * 100 / PawnValueEg;
else
ss << "mate " << (v > 0 ? VALUE_MATE - v + 1 : -VALUE_MATE - v) / 2;
ss << "cp " << v * 100 / PawnValueEg;
else
ss << "mate " << (v > 0 ? VALUE_MATE - v + 1 : -VALUE_MATE - v) / 2;