Fix discrepancy for ep square between set and move in the binpack lib.

basically, the binpack lib doesn't reset the epsquare after f7f5 in this 5kb1/5p2/2B3p1/1N1KP2p/3p1P2/2bP2P1/5r2/8 b - - 0 1 position, but it does reset it when passed the fen 5kb1/8/2B3p1/1N1KPp1p/3p1P2/2bP2P1/5r2/8 w - f6 0 50. Potentially creating a discrepancy based on whether the position was set directly or arrived at by a move
This commit is contained in:
Tomasz Sobczyk
2021-05-24 19:17:19 +02:00
parent cbd72299c1
commit ca365f17ba

View File

@@ -6078,18 +6078,14 @@ namespace chess
// for double pushes move index differs by 16 or -16;
if((movedPiece == PieceType::Pawn) & ((ordinal(move.to) ^ ordinal(move.from)) == 16))
{
const Square potentialEpSquare = fromOrdinal<Square>((ordinal(move.to) + ordinal(move.from)) >> 1);
// Even though the move has not yet been made we can safely call
// this function and get the right result because the position of the
// pawn to be captured is not really relevant.
if (isEpPossible(potentialEpSquare, !m_sideToMove))
{
m_epSquare = potentialEpSquare;
}
m_epSquare = fromOrdinal<Square>((ordinal(move.to) + ordinal(move.from)) >> 1);
}
const Piece captured = BaseType::doMove(move);
m_sideToMove = !m_sideToMove;
nullifyEpSquareIfNotPossible();
return { move, captured, oldEpSquare, oldCastlingRights };
}