Skip to content

Commit e0f39ce

Browse files
authored
Pawn shield (#114)
ELO | 5.38 +- 4.20 (95%) SPRT | 10.0+0.10s Threads=1 Hash=16MB LLR | 3.00 (-2.94, 2.94) [0.00, 5.00] GAMES | N: 15752 W: 4846 L: 4602 D: 6304 Bench: 8152978
1 parent ceb9145 commit e0f39ce

File tree

7 files changed

+133
-80
lines changed

7 files changed

+133
-80
lines changed

Bit-Genie/src/bitmask.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,46 @@ namespace BitMask
8282
0X2838000000000000, 0X5070000000000000, 0Xa0e0000000000000, 0X40c0000000000000
8383
};
8484

85+
constexpr uint64_t pawn_shield[total_colors][total_squares]
86+
{
87+
{
88+
0x0000000000000300, 0x0000000000000700, 0x0000000000000e00, 0x0000000000001c00,
89+
0x0000000000003800, 0x0000000000007000, 0x000000000000e000, 0x000000000000c000,
90+
0x0000000000030000, 0x0000000000070000, 0x00000000000e0000, 0x00000000001c0000,
91+
0x0000000000380000, 0x0000000000700000, 0x0000000000e00000, 0x0000000000c00000,
92+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
93+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
94+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
95+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
96+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
97+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
98+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
99+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
100+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
101+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
102+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
103+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
104+
},
105+
{
106+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
107+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
108+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
109+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
110+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
111+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
112+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
113+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
114+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
115+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
116+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
117+
0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000,
118+
0x0000030000000000, 0x0000070000000000, 0x00000e0000000000, 0x00001c0000000000,
119+
0x0000380000000000, 0x0000700000000000, 0x0000e00000000000, 0x0000c00000000000,
120+
0x0003000000000000, 0x0007000000000000, 0x000e000000000000, 0x001c000000000000,
121+
0x0038000000000000, 0x0070000000000000, 0x00e0000000000000, 0x00c0000000000000,
122+
},
123+
};
124+
85125
constexpr uint64_t pawn_attacks[total_colors][total_squares]{
86126
{
87127
0X000000000000000200, 0X000000000000000500, 0X000000000000000a00, 0X000000000000001400,

Bit-Genie/src/eval.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ int get_phase(Position const &position)
363363
static int evaluate_king(Position const &position, EvalData &data, Square sq, Color us)
364364
{
365365
Square relative_sq = psqt_sq(sq, us);
366+
uint64_t friend_pawns = position.pieces.get_piece_bb<Pawn>(us);
366367

367368
int score = KingEval::psqt[relative_sq];
368369
TRACE_3(psqt, King, relative_sq);
@@ -382,6 +383,10 @@ static int evaluate_king(Position const &position, EvalData &data, Square sq, Co
382383
TRACE_2(safety_table, weight);
383384
}
384385

386+
int shield_pawn_count = popcount64(friend_pawns & BitMask::pawn_shield[us][sq]);
387+
score += KingEval::pawn_shield[shield_pawn_count];
388+
TRACE_2(pawn_shield, shield_pawn_count);
389+
385390
return score;
386391
}
387392

0 commit comments

Comments
 (0)