rudzen / ChessLib

C# chess library containing a complete data structure and move generation.
MIT License
81 stars 22 forks source link

Bug in Disambiguation Logic for SAN Moves #32

Closed johnathandavis closed 4 years ago

johnathandavis commented 4 years ago

I see some notes in the "ToDo.txt" file about the notation improvements, but not sure if this is covered. Here's a short repro:

var pos = new Position(new Board(), new PieceValue());
var game = GameFactory.Create(pos);
game.NewGame("5r1k/p6p/4r1n1/3NPp2/8/8/PP4RP/4R1K1 w - - 3 53");
var sanMoves = game.Pos
    .GenerateMoves()
    .Select(
        m => new MoveAmbiguity(game.Pos)
            .ToNotation(m, MoveNotations.San));
bool hasRee2 = sanMoves.Contains("Ree2"); // This is true
bool hasRge2 = sanMoves.Contains("Rge2"); // This is false, this move remains Re2

It appears the disambiguation logic does not always add the rank or file characters.

rudzen commented 4 years ago

Nicely spotted 👍 I've identified the problem and a fix is in progress.

johnathandavis commented 4 years ago

Wow, thanks for the quick response!

I have a Chess logic library that can generate legal moves and interpret FEN strings, but it was written with verbosity as a feature, and thus is severely lacking in performance. Now, I'm using my PGN parsing library to import an open source database of 6 million games, and it takes forever, mostly due to the move generation. Your bitboard implementation should be a lot faster!

johnathandavis commented 4 years ago

Sorry, this is my first time creating an issue on a smaller project - did you want me to review that pull request? (I lack permissions, but if this is a solo project I'm happy to look it over if that would help, but if that wouldn't help, I can stay out of your business)

rudzen commented 4 years ago

It's a solo project, but if you find a bug (you can fix) you can of course do a PR. If you find the fix I did actually didn't fix the issue, just make a new issue. This issue will be closed when i merge the current work PR #31