Allow demotion of pieces
authorH.G.Muller <hgm@hgm-xboard.(none)>
Tue, 10 Apr 2018 16:11:19 +0000 (18:11 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Tue, 10 Apr 2018 16:16:43 +0000 (18:16 +0200)
The promoInc is now XORed with the moving piece, rather than ORed into it.
This allows moves that specify promotion (through off-board to-square) to
be applied to already promoted pieces, with as a result they revert to
their unpromoted form.

dropper.c

index 9d1188e..b8f8aa6 100644 (file)
--- a/dropper.c
+++ b/dropper.c
@@ -1073,7 +1073,7 @@ MakeMove (StackFrame *f, int move)
     f->fromPiece = board[f->fromSqr];                                   // occupant or (for drops) complemented holdings count
     if(f->checker != CK_NONE && NonEvade(f)) return 0;                  // abort if move did not evade existing check
     f->mutation = (f->fromPiece >> 7) | f->fromPiece;                   // occupant or (for drops) -1
-    f->toPiece = f->mutation + dropType[f->fromSqr] | promoInc[to];     // (possibly promoted) occupant or (for drops) piece to drop
+    f->toPiece = f->mutation + dropType[f->fromSqr] ^ promoInc[to];     // (possibly promoted) occupant or (for drops) piece to drop
     f->victim = board[f->captSqr];                                     // for now this is the replacement victim
     f->newEval = f->pstEval; f->newKey  = f->hashKey;                  // start building new key and eval
     f->epSqr = 255;