Menu

#32 pawn promotion + casuality bug

ictk v0.2.0
open
nobody
5
2011-04-05
2011-04-05
serhioms
No

Hi All,

I'd like to add my contribution to this great project!

Here are steps for reproduce the bug:
1. Do white pawn promotion to white Knight vie causality of black Knight (smth like getHistory().add(move);)
2. Then take move back like getHistory().prev(); or getHistory().removeLastMove();

After all you can find wrong piece on promoted square - white Knight instead of black Knight.

The reason is that promotion object are absolutely the same as casualty object in ChessMove.java class

I did not find the way haw it happens, but you can put patch like this in ChessMove.java class:

instead of lines (around line #442)

if (promotion == null) //auto promo
promotion = new Queen();

put lines like this:

if (promotion == null) //auto promo
promotion = new Queen();
else if( promotion == casualty )
promotion = toChessPiece(promotion.index);

Thank you,
Sergey

PS Have a good game...

Discussion


Log in to post a comment.

MongoDB Logo MongoDB