SebLague / Chess-Challenge

Create your own tiny chess bot!
https://www.youtube.com/watch?v=Ne40a5LkK6A
MIT License
1.77k stars 1.06k forks source link

move.IsCapture is true even when not a capture #370

Closed VictorChemin closed 1 year ago

VictorChemin commented 1 year ago

The program crashed every time I tried to get the value of a capture move because the "captured" piece was None. I tested if board.GetPiece(move.TargetSquare).PieceType.Equals(PieceType.None) && move.IsCapture could return true, and it can. With the exact same bots, this bug doesn't exist in 1.1, as board.GetPiece(move.TargetSquare).PieceType.Equals(PieceType.None) && move.IsCapture is always false.

You can test this by simply using the Practice Bot from Sebastian (https://github.com/fmoeran/Practice-Bot). At line 220, if you replace if (move.isCapture) with if (!board.GetPiece(move.TargetSquare).PieceType.Equals(PieceType.None)), the bot works fine again. Which shows that the problem comes from move.isCapture.

For some reason, move.isCapture isn't reliable anymore.

VictorChemin commented 1 year ago

It's the practice bot which was apparently incorrect as it was forgetting about en passant.