1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-29 16:23:09 +00:00

Tweak unstoppable pawns detection

A pawn is unstoppable also if enemy king can reach it
but path to queening is protected.

Original idea by Ralph Stoesser fixed by me.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2010-06-13 11:05:04 +01:00
parent a010d438a2
commit 74db0f0f40

View file

@ -900,13 +900,16 @@ namespace {
- square_distance(pos.king_square(opposite_color(c)), queeningSquare) - square_distance(pos.king_square(opposite_color(c)), queeningSquare)
+ int(c != pos.side_to_move()); + int(c != pos.side_to_move());
if (d < 0) // Do we protect the path to queening ?
bool pathDefended = (ei.attacked_by(c) & squares_in_front_of(c, s)) == squares_in_front_of(c, s);
if (d < 0 || pathDefended)
{ {
int mtg = RANK_8 - relative_rank(c, s); int mtg = RANK_8 - relative_rank(c, s);
int blockerCount = count_1s_max_15(squares_in_front_of(c, s) & pos.occupied_squares()); int blockerCount = count_1s_max_15(squares_in_front_of(c, s) & pos.occupied_squares());
mtg += blockerCount; mtg += blockerCount;
d += blockerCount; d += blockerCount;
if (d < 0 && (!movesToGo[c] || movesToGo[c] > mtg)) if ((d < 0 || pathDefended) && (!movesToGo[c] || movesToGo[c] > mtg))
{ {
movesToGo[c] = mtg; movesToGo[c] = mtg;
pawnToGo[c] = s; pawnToGo[c] = s;