Incorrect SAN Notation
skotz opened this issue · 1 comments
skotz commented
The SAN notation isn't appending the +
and #
appropriately in all cases.
I was going to submit a pull request to fix this but it ended up being a bit more involved than I have time for right now, so here's at least a few unit tests that demonstrate the issue.
Here's a position where a rook capture with check should have a plus on it.
[Theory]
[InlineData("2rr2k1/p3ppbp/b1n3p1/2p1P3/5P2/2N3P1/PP2N1BP/3R1RK1 w - - 2 18", "Rxd8+")]
public void SanCaptureWithCheck(string fen, string expected)
{
var game = GameFactory.Create(fen);
var notation = MoveNotation.Create(game.Pos);
var move = Move.Create(Squares.d1, Squares.d8, MoveTypes.Normal);
var sanMove = notation.ToNotation(MoveNotations.San).Convert(move);
// Capturing a piece with check
Assert.Equal(sanMove, expected);
}
Here's a position where a player is currently in check and must play one of three moves to get out of check. The moves currently all get parsed as checkmate, which isn't correct.
[Theory]
[InlineData("2rR2k1/p3ppbp/b1n3p1/2p1P3/5P2/2N3P1/PP2N1BP/5RK1 b - - 0 36", "Nxb8", "Rxb8", "Bf8")]
public void SanRecaptureNotCheckmate(string fen, params string[] expected)
{
var game = GameFactory.Create(fen);
var notation = MoveNotation.Create(game.Pos);
var allMoves = MoveFactory.GenerateMoves(game.Pos);
foreach (var move in allMoves)
{
var sanMove = notation.ToNotation(MoveNotations.San).Convert(move);
// Recapturing a piece to remove the check
Assert.Contains(sanMove, expected);
}
}
Thanks
rudzen commented
Interesting catch, however it looks like the second one of your examples should be expected moves to be
"Nxd8", "Rxd8", "Bf8"
(d instead of b).