mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
Retire updateKingTables[]
Suggested by Marek Kwiatkowski. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
1bbbc13b46
commit
f00c976bb2
1 changed files with 10 additions and 13 deletions
|
@ -45,11 +45,6 @@ namespace {
|
||||||
// Pointer to pawn hash table entry
|
// Pointer to pawn hash table entry
|
||||||
PawnInfo* pi;
|
PawnInfo* pi;
|
||||||
|
|
||||||
// updateKingTables[color] is set to true if we have enough material
|
|
||||||
// to trigger the opponent's king safety calculation. When is false we
|
|
||||||
// skip the time consuming update of the king attackers tables.
|
|
||||||
bool updateKingTables[2];
|
|
||||||
|
|
||||||
// attackedBy[color][piece type] is a bitboard representing all squares
|
// attackedBy[color][piece type] is a bitboard representing all squares
|
||||||
// attacked by a given color and piece type, attackedBy[color][0] contains
|
// attacked by a given color and piece type, attackedBy[color][0] contains
|
||||||
// all squares attacked by the given color.
|
// all squares attacked by the given color.
|
||||||
|
@ -443,14 +438,17 @@ namespace {
|
||||||
|
|
||||||
Bitboard b = ei.attackedBy[Them][KING] = pos.attacks_from<KING>(pos.king_square(Them));
|
Bitboard b = ei.attackedBy[Them][KING] = pos.attacks_from<KING>(pos.king_square(Them));
|
||||||
ei.attackedBy[Us][PAWN] = ei.pi->pawn_attacks(Us);
|
ei.attackedBy[Us][PAWN] = ei.pi->pawn_attacks(Us);
|
||||||
ei.updateKingTables[Us] = pos.piece_count(Us, QUEEN) && pos.non_pawn_material(Us) >= QueenValueMidgame + RookValueMidgame;
|
|
||||||
if (ei.updateKingTables[Us])
|
// Init king safety tables only if we are going to use them
|
||||||
|
if ( pos.piece_count(Us, QUEEN)
|
||||||
|
&& pos.non_pawn_material(Us) >= QueenValueMidgame + RookValueMidgame)
|
||||||
{
|
{
|
||||||
ei.kingZone[Us] = (b | (Us == WHITE ? b >> 8 : b << 8));
|
ei.kingZone[Us] = (b | (Us == WHITE ? b >> 8 : b << 8));
|
||||||
b &= ei.attackedBy[Us][PAWN];
|
b &= ei.attackedBy[Us][PAWN];
|
||||||
ei.kingAttackersCount[Us] = b ? count_1s<Max15>(b) / 2 : EmptyBoardBB;
|
ei.kingAttackersCount[Us] = b ? count_1s<Max15>(b) / 2 : 0;
|
||||||
ei.kingAdjacentZoneAttacksCount[Us] = ei.kingAttackersWeight[Us] = EmptyBoardBB;
|
ei.kingAdjacentZoneAttacksCount[Us] = ei.kingAttackersWeight[Us] = 0;
|
||||||
}
|
} else
|
||||||
|
ei.kingZone[Us] = ei.kingAttackersCount[Us] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -514,7 +512,7 @@ namespace {
|
||||||
ei.attackedBy[Us][Piece] |= b;
|
ei.attackedBy[Us][Piece] |= b;
|
||||||
|
|
||||||
// King attacks
|
// King attacks
|
||||||
if (ei.updateKingTables[Us] && (b & ei.kingZone[Us]))
|
if (b & ei.kingZone[Us])
|
||||||
{
|
{
|
||||||
ei.kingAttackersCount[Us]++;
|
ei.kingAttackersCount[Us]++;
|
||||||
ei.kingAttackersWeight[Us] += KingAttackWeights[Piece];
|
ei.kingAttackersWeight[Us] += KingAttackWeights[Piece];
|
||||||
|
@ -666,8 +664,7 @@ namespace {
|
||||||
|
|
||||||
// King safety. This is quite complicated, and is almost certainly far
|
// King safety. This is quite complicated, and is almost certainly far
|
||||||
// from optimally tuned.
|
// from optimally tuned.
|
||||||
if ( ei.updateKingTables[Them]
|
if ( ei.kingAttackersCount[Them] >= 2
|
||||||
&& ei.kingAttackersCount[Them] >= 2
|
|
||||||
&& ei.kingAdjacentZoneAttacksCount[Them])
|
&& ei.kingAdjacentZoneAttacksCount[Them])
|
||||||
{
|
{
|
||||||
// Find the attacked squares around the king which has no defenders
|
// Find the attacked squares around the king which has no defenders
|
||||||
|
|
Loading…
Add table
Reference in a new issue