Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 6 additions & 16 deletions src/evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ namespace {
{
ei.kingRing[Them] = b | shift_bb<Down>(b);
b &= ei.attackedBy[Us][PAWN];
ei.kingAttackersCount[Us] = b ? popcount(b) : 0;
ei.kingAttackersCount[Us] = popcount(b);
ei.kingAdjacentZoneAttacksCount[Us] = ei.kingAttackersWeight[Us] = 0;
}
else
Expand Down Expand Up @@ -276,9 +276,7 @@ namespace {
{
ei.kingAttackersCount[Us]++;
ei.kingAttackersWeight[Us] += KingAttackWeights[Pt];
bb = b & ei.attackedBy[Them][KING];
if (bb)
ei.kingAdjacentZoneAttacksCount[Us] += popcount(bb);
ei.kingAdjacentZoneAttacksCount[Us] += popcount(b & ei.attackedBy[Them][KING]);
}

if (Pt == QUEEN)
Expand Down Expand Up @@ -331,11 +329,7 @@ namespace {
{
// Bonus for aligning with enemy pawns on the same rank/file
if (relative_rank(Us, s) >= RANK_5)
{
Bitboard alignedPawns = pos.pieces(Them, PAWN) & PseudoAttacks[ROOK][s];
if (alignedPawns)
score += RookOnPawn * popcount(alignedPawns);
}
score += RookOnPawn * popcount(pos.pieces(Them, PAWN) & PseudoAttacks[ROOK][s]);

// Bonus when on an open or semi-open file
if (ei.pi->semiopen_file(Us, file_of(s)))
Expand Down Expand Up @@ -417,8 +411,7 @@ namespace {
| ei.attackedBy[Them][BISHOP] | ei.attackedBy[Them][ROOK]
| ei.attackedBy[Them][KING];

if (b)
attackUnits += QueenContactCheck * popcount(b);
attackUnits += QueenContactCheck * popcount(b);
}

// Analyse the enemy's safe distance checks for sliders and knights
Expand Down Expand Up @@ -514,9 +507,7 @@ namespace {
while (b)
score += Threat[Rook ][type_of(pos.piece_on(pop_lsb(&b)))];

b = weak & ~ei.attackedBy[Them][ALL_PIECES];
if (b)
score += Hanging * popcount(b);
score += Hanging * popcount(weak & ~ei.attackedBy[Them][ALL_PIECES]);

b = weak & ei.attackedBy[Us][KING];
if (b)
Expand All @@ -535,8 +526,7 @@ namespace {
& pos.pieces(Them)
& ~ei.attackedBy[Us][PAWN];

if (b)
score += ThreatByPawnPush * popcount(b);
score += ThreatByPawnPush * popcount(b);

if (DoTrace)
Trace::add(THREAT, Us, score);
Expand Down
2 changes: 1 addition & 1 deletion src/movegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ namespace {
&& !(PseudoAttacks[Pt][from] & target & ci->checkSquares[Pt]))
continue;

if (ci->dcCandidates && (ci->dcCandidates & from))
if (ci->dcCandidates & from)
continue;
}

Expand Down
6 changes: 2 additions & 4 deletions src/position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,7 @@ bool Position::legal(Move m, Bitboard pinned) const {

// A non-king move is legal if and only if it is not pinned or it
// is moving along the ray towards or away from the king.
return !pinned
|| !(pinned & from)
return !(pinned & from)
|| aligned(from, to_sq(m), square<KING>(us));
}

Expand Down Expand Up @@ -595,8 +594,7 @@ bool Position::gives_check(Move m, const CheckInfo& ci) const {
return true;

// Is there a discovered check?
if ( ci.dcCandidates
&& (ci.dcCandidates & from)
if ( (ci.dcCandidates & from)
&& !aligned(from, to, ci.ksq))
return true;

Expand Down