Skip to content

Commit 402a7ae

Browse files
Ralph Stößermcostalba
authored andcommitted
Ad-hoc shelter rule
This hacky rule allows to get an about right eval out of this position: r2qk2r/ppp2p2/2npbn2/2b1p3/2P1P1P1/2NB1PPp/PPNP3K/R1BQ1R2 b kq - 0 13 And, more importantly, passed both short TC: LLR: 2.95 (-2.94,2.94) [-1.50,4.50] Total: 6239 W: 1249 L: 1127 D: 3863 And long TC: LLR: 2.96 (-2.94,2.94) [0.00,6.00] Total: 38371 W: 6165 L: 5888 D: 26318 bench: 8183238
1 parent 3d58092 commit 402a7ae

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/pawns.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ template<Color Us>
240240
Value Entry::shelter_storm(const Position& pos, Square ksq) {
241241

242242
const Color Them = (Us == WHITE ? BLACK : WHITE);
243+
static const Bitboard MiddleEdges = (FileABB | FileHBB) & (Rank2BB | Rank3BB);
243244

244245
Value safety = MaxSafetyBonus;
245246
Bitboard b = pos.pieces(PAWN) & (in_front_bb(Us, rank_of(ksq)) | rank_bb(ksq));
@@ -252,11 +253,17 @@ Value Entry::shelter_storm(const Position& pos, Square ksq) {
252253
{
253254
b = ourPawns & file_bb(f);
254255
rkUs = b ? relative_rank(Us, backmost_sq(Us, b)) : RANK_1;
255-
safety -= ShelterWeakness[rkUs];
256256

257257
b = theirPawns & file_bb(f);
258258
rkThem = b ? relative_rank(Us, frontmost_sq(Them, b)) : RANK_1;
259-
safety -= StormDanger[rkUs == RANK_1 ? 0 : rkThem == rkUs + 1 ? 2 : 1][rkThem];
259+
260+
if ( (MiddleEdges & (f | rkThem))
261+
&& file_of(ksq) == f
262+
&& relative_rank(Us, ksq) == rkThem - 1)
263+
safety += Value(200);
264+
else
265+
safety -= ShelterWeakness[rkUs]
266+
+ StormDanger[rkUs == RANK_1 ? 0 : rkThem == rkUs + 1 ? 2 : 1][rkThem];
260267
}
261268

262269
return safety;

0 commit comments

Comments
 (0)