CXXFLAGS += -fno-gcse -mthumb -march=armv7-a -mfloat-abi=softfp
endif
endif
-
+
ifeq ($(comp),$(filter $(comp),gcc clang icc))
ifeq ($(KERNEL),Darwin)
CXXFLAGS += -mdynamic-no-pic
int kingFlankAttacks = popcount(b1) + popcount(b2);
kingDanger += kingAttackersCount[Them] * kingAttackersWeight[Them]
- + 69 * kingAttacksCount[Them]
+ 185 * popcount(kingRing[Us] & weak)
- - 100 * bool(attackedBy[Us][KNIGHT] & attackedBy[Us][KING])
- - 35 * bool(attackedBy[Us][BISHOP] & attackedBy[Us][KING])
+ 148 * popcount(unsafeChecks)
+ 98 * popcount(pos.blockers_for_king(Us))
+ + 69 * kingAttacksCount[Them]
+ + 3 * kingFlankAttacks * kingFlankAttacks / 8
+ + mg_value(mobility[Them] - mobility[Us])
- 873 * !pos.count<QUEEN>(Them)
+ - 100 * bool(attackedBy[Us][KNIGHT] & attackedBy[Us][KING])
+ - 35 * bool(attackedBy[Us][BISHOP] & attackedBy[Us][KING])
- 6 * mg_value(score) / 8
- + mg_value(mobility[Them] - mobility[Us])
- + 3 * kingFlankAttacks * kingFlankAttacks / 8
- 7;
// Transform the kingDanger units into a Score, and subtract it from the evaluation
assert(!(pos.pieces(Them, PAWN) & forward_file_bb(Us, s + Up)));
int r = relative_rank(Us, s);
- File f = file_of(s);
Score bonus = PassedRank[r];
|| (pos.pieces(PAWN) & (s + Up)))
bonus = bonus / 2;
- score += bonus - PassedFile * map_to_queenside(f);
+ score += bonus - PassedFile * map_to_queenside(file_of(s));
}
if (T)
else
sf = std::min(sf, 36 + (pos.opposite_bishops() ? 2 : 7) * pos.count<PAWN>(strongSide));
- sf = std::max(0, sf - (pos.rule50_count() - 12) / 4 );
+ sf = std::max(0, sf - (pos.rule50_count() - 12) / 4);
}
return ScaleFactor(sf);
constexpr Direction UpRight = (Us == WHITE ? NORTH_EAST : SOUTH_WEST);
constexpr Direction UpLeft = (Us == WHITE ? NORTH_WEST : SOUTH_EAST);
+ const Square ksq = pos.square<KING>(Them);
Bitboard emptySquares;
Bitboard pawnsOn7 = pos.pieces(Us, PAWN) & TRank7BB;
if (Type == QUIET_CHECKS)
{
- Square ksq = pos.square<KING>(Them);
-
b1 &= pos.attacks_from<PAWN>(ksq, Them);
b2 &= pos.attacks_from<PAWN>(ksq, Them);
Bitboard b2 = shift<UpLeft >(pawnsOn7) & enemies;
Bitboard b3 = shift<Up >(pawnsOn7) & emptySquares;
- Square ksq = pos.square<KING>(Them);
-
while (b1)
moveList = make_promotions<Type, UpRight>(moveList, pop_lsb(&b1), ksq);
ExtMove* generate_moves(const Position& pos, ExtMove* moveList, Color us,
Bitboard target) {
- assert(Pt != KING && Pt != PAWN);
+ static_assert(Pt != KING && Pt != PAWN, "Unsupported piece type in generate_moves()");
const Square* pl = pos.squares<Pt>(us);
template<GenType Type>
ExtMove* generate(const Position& pos, ExtMove* moveList) {
- assert(Type == CAPTURES || Type == QUIETS || Type == NON_EVASIONS);
+ static_assert(Type == CAPTURES || Type == QUIETS || Type == NON_EVASIONS, "Unsupported type in generate()");
assert(!pos.checkers());
Color us = pos.side_to_move();
// A pawn is backward when it is behind all pawns of the same color on
// the adjacent files and cannot safely advance.
backward = !(neighbours & forward_ranks_bb(Them, s + Up))
- && (stoppers & (leverPush | blocked));
+ && (leverPush | blocked);
// Compute additional span if pawn is not backward nor blocked
if (!backward && !blocked)
template<PieceType Pt>
inline Bitboard Position::attacks_from(Square s) const {
- assert(Pt != PAWN);
+ static_assert(Pt != PAWN, "Pawn attacks need color");
+
return Pt == BISHOP || Pt == ROOK ? attacks_bb<Pt>(s, byTypeBB[ALL_PIECES])
: Pt == QUEEN ? attacks_from<ROOK>(s) | attacks_from<BISHOP>(s)
: PseudoAttacks[Pt][s];
return (r + 520) / 1024 + (!i && r > 999);
}
- constexpr int futility_move_count(bool improving, int depth) {
+ constexpr int futility_move_count(bool improving, Depth depth) {
return (5 + depth * depth) * (1 + improving) / 2;
}
Move ttMove, move, excludedMove, bestMove;
Depth extension, newDepth;
Value bestValue, value, ttValue, eval, maxValue;
- bool ttHit, ttPv, inCheck, givesCheck, improving, doLMR, priorCapture;
+ bool ttHit, ttPv, inCheck, givesCheck, improving, didLMR, priorCapture;
bool captureOrPromotion, doFullDepthSearch, moveCountPruning, ttCapture, singularLMR;
Piece movedPiece;
int moveCount, captureCount, quietCount;
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, d, true);
- doFullDepthSearch = (value > alpha && d != newDepth), doLMR = true;
+ doFullDepthSearch = (value > alpha && d != newDepth), didLMR = true;
}
else
- doFullDepthSearch = !PvNode || moveCount > 1, doLMR = false;
+ doFullDepthSearch = !PvNode || moveCount > 1, didLMR = false;
// Step 17. Full depth search when LMR is skipped or fails high
if (doFullDepthSearch)
{
value = -search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth, !cutNode);
- if (doLMR && !captureOrPromotion)
+ if (didLMR && !captureOrPromotion)
{
int bonus = value > alpha ? stat_bonus(newDepth)
: -stat_bonus(newDepth);
// Don't search moves with negative SEE values
if ( (!inCheck || evasionPrunable)
- && (!givesCheck || !(pos.blockers_for_king(~pos.side_to_move()) & from_sq(move)))
+ && !(givesCheck && pos.is_discovery_check_on_king(~pos.side_to_move(), move))
&& !pos.see_ge(move))
continue;
std::swap(squares[0], *std::max_element(squares, squares + leadPawnsCnt, pawns_comp));
- tbFile = file_of(squares[0]);
- if (tbFile > FILE_D)
- tbFile = file_of(squares[0] ^ 7); // Horizontal flip: SQ_H1 -> SQ_A1
+ tbFile = map_to_queenside(file_of(squares[0]));
}
// DTZ tables are one-sided, i.e. they store positions only for white to
enum { Split = 1, HasPawns = 2 };
- assert(e.hasPawns == !!(*data & HasPawns));
- assert((e.key != e.key2) == !!(*data & Split));
+ assert(e.hasPawns == bool(*data & HasPawns));
+ assert((e.key != e.key2) == bool(*data & Split));
data++; // First byte stores flags
captureHistory.fill(0);
for (bool inCheck : { false, true })
- for (StatsType c : { NoCaptures, Captures })
- for (auto& to : continuationHistory[inCheck][c])
- for (auto& h : to)
- h->fill(0);
+ for (StatsType c : { NoCaptures, Captures })
+ for (auto& to : continuationHistory[inCheck][c])
+ for (auto& h : to)
+ h->fill(0);
for (bool inCheck : { false, true })
- for (StatsType c : { NoCaptures, Captures })
+ for (StatsType c : { NoCaptures, Captures })
continuationHistory[inCheck][c][NO_PIECE][0]->fill(Search::CounterMovePruneThreshold - 1);
}
return result;
}
-/// Multiplication of a Score by an boolean
+/// Multiplication of a Score by a boolean
inline Score operator*(Score s, bool b) {
return Score(int(s) * int(b));
}