mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Remove some pointless micro-optimizations
Seems to give around 1% speed-up for CPUs with popcnt support. Seems to give a very minor speed-up for CPUs without popcnt. No functional change Resolves #646
This commit is contained in:
parent
94e41274bb
commit
c737062436
3 changed files with 9 additions and 21 deletions
|
@ -234,7 +234,7 @@ namespace {
|
||||||
{
|
{
|
||||||
ei.kingRing[Them] = b | shift_bb<Down>(b);
|
ei.kingRing[Them] = b | shift_bb<Down>(b);
|
||||||
b &= ei.attackedBy[Us][PAWN];
|
b &= ei.attackedBy[Us][PAWN];
|
||||||
ei.kingAttackersCount[Us] = b ? popcount(b) : 0;
|
ei.kingAttackersCount[Us] = popcount(b);
|
||||||
ei.kingAdjacentZoneAttacksCount[Us] = ei.kingAttackersWeight[Us] = 0;
|
ei.kingAdjacentZoneAttacksCount[Us] = ei.kingAttackersWeight[Us] = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -276,9 +276,7 @@ namespace {
|
||||||
{
|
{
|
||||||
ei.kingAttackersCount[Us]++;
|
ei.kingAttackersCount[Us]++;
|
||||||
ei.kingAttackersWeight[Us] += KingAttackWeights[Pt];
|
ei.kingAttackersWeight[Us] += KingAttackWeights[Pt];
|
||||||
bb = b & ei.attackedBy[Them][KING];
|
ei.kingAdjacentZoneAttacksCount[Us] += popcount(b & ei.attackedBy[Them][KING]);
|
||||||
if (bb)
|
|
||||||
ei.kingAdjacentZoneAttacksCount[Us] += popcount(bb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Pt == QUEEN)
|
if (Pt == QUEEN)
|
||||||
|
@ -331,11 +329,7 @@ namespace {
|
||||||
{
|
{
|
||||||
// Bonus for aligning with enemy pawns on the same rank/file
|
// Bonus for aligning with enemy pawns on the same rank/file
|
||||||
if (relative_rank(Us, s) >= RANK_5)
|
if (relative_rank(Us, s) >= RANK_5)
|
||||||
{
|
score += RookOnPawn * popcount(pos.pieces(Them, PAWN) & PseudoAttacks[ROOK][s]);
|
||||||
Bitboard alignedPawns = pos.pieces(Them, PAWN) & PseudoAttacks[ROOK][s];
|
|
||||||
if (alignedPawns)
|
|
||||||
score += RookOnPawn * popcount(alignedPawns);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bonus when on an open or semi-open file
|
// Bonus when on an open or semi-open file
|
||||||
if (ei.pi->semiopen_file(Us, file_of(s)))
|
if (ei.pi->semiopen_file(Us, file_of(s)))
|
||||||
|
@ -417,7 +411,6 @@ namespace {
|
||||||
| ei.attackedBy[Them][BISHOP] | ei.attackedBy[Them][ROOK]
|
| ei.attackedBy[Them][BISHOP] | ei.attackedBy[Them][ROOK]
|
||||||
| ei.attackedBy[Them][KING];
|
| ei.attackedBy[Them][KING];
|
||||||
|
|
||||||
if (b)
|
|
||||||
attackUnits += QueenContactCheck * popcount(b);
|
attackUnits += QueenContactCheck * popcount(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,9 +507,7 @@ namespace {
|
||||||
while (b)
|
while (b)
|
||||||
score += Threat[Rook ][type_of(pos.piece_on(pop_lsb(&b)))];
|
score += Threat[Rook ][type_of(pos.piece_on(pop_lsb(&b)))];
|
||||||
|
|
||||||
b = weak & ~ei.attackedBy[Them][ALL_PIECES];
|
score += Hanging * popcount(weak & ~ei.attackedBy[Them][ALL_PIECES]);
|
||||||
if (b)
|
|
||||||
score += Hanging * popcount(b);
|
|
||||||
|
|
||||||
b = weak & ei.attackedBy[Us][KING];
|
b = weak & ei.attackedBy[Us][KING];
|
||||||
if (b)
|
if (b)
|
||||||
|
@ -535,7 +526,6 @@ namespace {
|
||||||
& pos.pieces(Them)
|
& pos.pieces(Them)
|
||||||
& ~ei.attackedBy[Us][PAWN];
|
& ~ei.attackedBy[Us][PAWN];
|
||||||
|
|
||||||
if (b)
|
|
||||||
score += ThreatByPawnPush * popcount(b);
|
score += ThreatByPawnPush * popcount(b);
|
||||||
|
|
||||||
if (DoTrace)
|
if (DoTrace)
|
||||||
|
|
|
@ -239,7 +239,7 @@ namespace {
|
||||||
&& !(PseudoAttacks[Pt][from] & target & ci->checkSquares[Pt]))
|
&& !(PseudoAttacks[Pt][from] & target & ci->checkSquares[Pt]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (ci->dcCandidates && (ci->dcCandidates & from))
|
if (ci->dcCandidates & from)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
// 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.
|
// is moving along the ray towards or away from the king.
|
||||||
return !pinned
|
return !(pinned & from)
|
||||||
|| !(pinned & from)
|
|
||||||
|| aligned(from, to_sq(m), square<KING>(us));
|
|| aligned(from, to_sq(m), square<KING>(us));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,8 +594,7 @@ bool Position::gives_check(Move m, const CheckInfo& ci) const {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Is there a discovered check?
|
// Is there a discovered check?
|
||||||
if ( ci.dcCandidates
|
if ( (ci.dcCandidates & from)
|
||||||
&& (ci.dcCandidates & from)
|
|
||||||
&& !aligned(from, to, ci.ksq))
|
&& !aligned(from, to, ci.ksq))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue