Geras1mleo / Chess

C# .NET 6.0 Chess Library
MIT License
49 stars 15 forks source link

False positives on Move.InCheck on promotion moves #8

Closed manushand closed 1 year ago

manushand commented 1 year ago

Describe the bug A move that promotes a pawn to a piece that does not deliver check is mistakenly set to IsCheck=true if there are other possible promotions (that is, to other pieces) that WOULD give check.

To Reproduce

var board = ChessBoard.LoadFromFen("k7/7P/8/8/8/8/8/K7 w - - 0 1");
var checks = board.Moves().Where(static move => move.IsCheck).ToList();

You will see that checks.Count is 4, when it should be 2, and that the List includes both h8=N+ and h8=B+ when neither of these promotions actually deliver check.

Expected behaviour Moves that promote to pieces that do not deliver check should have Move.IsCheck == false. In the example code above, the checks List should contain only two moves: h8=Q+ and h8=R+

Screenshots N/A

Additional context N/A

Geras1mleo commented 1 year ago

I'll take a look at this one shortly. I appreciate your feedback!

manushand commented 1 year ago

I'll take a look at this one shortly. I appreciate your feedback!

Thank you! I imagine you will notice, but I believe this same bug also applies to Move.IsMate.

manushand commented 1 year ago

THANKS SO MUCH for your prompt attention to this one!!