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

denormalize KRKP.

a non-functional code style change that denormalizes the KRKP endgame,
making it somewhat easier to read.

closes https://github.com/official-stockfish/Stockfish/pull/2786

No functional change
This commit is contained in:
protonspring 2020-06-30 10:17:50 -06:00 committed by Joost VandeVondele
parent 67818ee948
commit c5b2a92cd1

View file

@ -181,15 +181,15 @@ Value Endgame<KRKP>::operator()(const Position& pos) const {
assert(verify_material(pos, strongSide, RookValueMg, 0)); assert(verify_material(pos, strongSide, RookValueMg, 0));
assert(verify_material(pos, weakSide, VALUE_ZERO, 1)); assert(verify_material(pos, weakSide, VALUE_ZERO, 1));
Square strongKing = relative_square(strongSide, pos.square<KING>(strongSide)); Square strongKing = pos.square<KING>(strongSide);
Square weakKing = relative_square(strongSide, pos.square<KING>(weakSide)); Square weakKing = pos.square<KING>(weakSide);
Square strongRook = relative_square(strongSide, pos.square<ROOK>(strongSide)); Square strongRook = pos.square<ROOK>(strongSide);
Square weakPawn = relative_square(strongSide, pos.square<PAWN>(weakSide)); Square weakPawn = pos.square<PAWN>(weakSide);
Square queeningSquare = make_square(file_of(weakPawn), RANK_1); Square queeningSquare = make_square(file_of(weakPawn), relative_rank(weakSide, RANK_8));
Value result; Value result;
// If the stronger side's king is in front of the pawn, it's a win // If the stronger side's king is in front of the pawn, it's a win
if (forward_file_bb(WHITE, strongKing) & weakPawn) if (forward_file_bb(strongSide, strongKing) & weakPawn)
result = RookValueEg - distance(strongKing, weakPawn); result = RookValueEg - distance(strongKing, weakPawn);
// If the weaker side's king is too far from the pawn and the rook, // If the weaker side's king is too far from the pawn and the rook,
@ -200,15 +200,15 @@ Value Endgame<KRKP>::operator()(const Position& pos) const {
// If the pawn is far advanced and supported by the defending king, // If the pawn is far advanced and supported by the defending king,
// the position is drawish // the position is drawish
else if ( rank_of(weakKing) <= RANK_3 else if ( relative_rank(strongSide, weakKing) <= RANK_3
&& distance(weakKing, weakPawn) == 1 && distance(weakKing, weakPawn) == 1
&& rank_of(strongKing) >= RANK_4 && relative_rank(strongSide, strongKing) >= RANK_4
&& distance(strongKing, weakPawn) > 2 + (pos.side_to_move() == strongSide)) && distance(strongKing, weakPawn) > 2 + (pos.side_to_move() == strongSide))
result = Value(80) - 8 * distance(strongKing, weakPawn); result = Value(80) - 8 * distance(strongKing, weakPawn);
else else
result = Value(200) - 8 * ( distance(strongKing, weakPawn + SOUTH) result = Value(200) - 8 * ( distance(strongKing, weakPawn + pawn_push(weakSide))
- distance(weakKing, weakPawn + SOUTH) - distance(weakKing, weakPawn + pawn_push(weakSide))
- distance(weakPawn, queeningSquare)); - distance(weakPawn, queeningSquare));
return strongSide == pos.side_to_move() ? result : -result; return strongSide == pos.side_to_move() ? result : -result;