mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
Calculate min distance between king and his pawns
Just added infrastructure. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
parent
0446fc85de
commit
9793fa1906
4 changed files with 14 additions and 0 deletions
|
@ -45,6 +45,7 @@ Bitboard ThisAndAdjacentFilesBB[8];
|
|||
Bitboard InFrontBB[2][8];
|
||||
Bitboard StepAttacksBB[16][64];
|
||||
Bitboard BetweenBB[64][64];
|
||||
Bitboard DistanceRingsBB[64][8];
|
||||
Bitboard ForwardBB[2][64];
|
||||
Bitboard PassedPawnMask[2][64];
|
||||
Bitboard AttackSpanMask[2][64];
|
||||
|
@ -195,6 +196,12 @@ void Bitboards::init() {
|
|||
for (Square s2 = SQ_A1; s2 <= SQ_H8; s2++)
|
||||
SquareDistance[s1][s2] = std::max(file_distance(s1, s2), rank_distance(s1, s2));
|
||||
|
||||
for (Square s1 = SQ_A1; s1 <= SQ_H8; s1++)
|
||||
for (int d = 1; d < 8; d++)
|
||||
for (Square s2 = SQ_A1; s2 <= SQ_H8; s2++)
|
||||
if (SquareDistance[s1][s2] == d)
|
||||
DistanceRingsBB[s1][d - 1] |= s2;
|
||||
|
||||
for (int i = 0; i < 64; i++)
|
||||
if (!Is64Bit) // Matt Taylor's folding trick for 32 bit systems
|
||||
{
|
||||
|
|
|
@ -50,6 +50,7 @@ extern Bitboard ThisAndAdjacentFilesBB[8];
|
|||
extern Bitboard InFrontBB[2][8];
|
||||
extern Bitboard StepAttacksBB[16][64];
|
||||
extern Bitboard BetweenBB[64][64];
|
||||
extern Bitboard DistanceRingsBB[64][8];
|
||||
extern Bitboard ForwardBB[2][64];
|
||||
extern Bitboard PassedPawnMask[2][64];
|
||||
extern Bitboard AttackSpanMask[2][64];
|
||||
|
|
|
@ -261,6 +261,11 @@ Score PawnEntry::update_safety(const Position& pos, Square ksq) {
|
|||
|
||||
kingSquares[Us] = ksq;
|
||||
castleRights[Us] = pos.can_castle(Us);
|
||||
minKPdistance[Us] = 0;
|
||||
|
||||
Bitboard pawns = pos.pieces(Us, PAWN);
|
||||
if (pawns)
|
||||
while (!(DistanceRingsBB[ksq][minKPdistance[Us]++] & pawns)) {}
|
||||
|
||||
if (relative_rank(Us, ksq) > RANK_4)
|
||||
return kingSafety[Us] = SCORE_ZERO;
|
||||
|
|
|
@ -59,6 +59,7 @@ private:
|
|||
Bitboard passedPawns[2];
|
||||
Bitboard pawnAttacks[2];
|
||||
Square kingSquares[2];
|
||||
int minKPdistance[2];
|
||||
int castleRights[2];
|
||||
Score value;
|
||||
int halfOpenFiles[2];
|
||||
|
|
Loading…
Add table
Reference in a new issue