From: H.G.Muller Date: Tue, 10 Apr 2018 16:59:18 +0000 (+0200) Subject: Make entry of promoting drops possible X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=0c6f316855a573034b0bd08fbe5d3518d7f461c9;p=crazywa.git Make entry of promoting drops possible If the piece IDs string also specifies IDs for promoted pieces, using such an ID in drop moves will encode the move as a drop of the unpromoted partner, plus a promotion. Use of such IDs in a FEN would be automatically understood. On output moves that are encoded as promotion and drop will use the ID specified for the promoted piece (rather than a + suffix on the drop). --- diff --git a/dropper.c b/dropper.c index b8f8aa6..6ec2a14 100644 --- a/dropper.c +++ b/dropper.c @@ -1626,8 +1626,11 @@ MoveToText (int move) if(inc > 0) promo = pieceID[inc - 16]; // move is promotion else if(castle) to = 2*to - from; // move is castling, and 'to' indicates Rook; calculate King to-square if(promo == '+' && !perpLoses) promo = 'q'; - if(from%22 > 10) sprintf(buf, "%c@%c%d", pieces[dropType[from]-1&~COLOR], 'a'+(to%22), 1+(to/22)); // move is drop - else sprintf(buf, "%c%d%c%d%c", 'a'+(from%22), 1+(from/22), 'a'+(to%22), 1+(to/22), promo); + if(from%22 > 10) { // move is drop + int p = dropType[from] - 1; + if(inc) p += 16; // promotion drop + sprintf(buf, "%c@%c%d", pieces[p&~COLOR], 'a'+(to%22), 1+(to/22)); + } else sprintf(buf, "%c%d%c%d%c", 'a'+(from%22), 1+(from/22), 'a'+(to%22), 1+(to/22), promo); return buf; } @@ -1640,7 +1643,8 @@ ParseMove(int stm, char *s) f -= 'a', r--; m = 22*r + f; for(i=0; pieces[i]; i++) if(pieces[i] == piece) break; - m += handSlot[COLOR - stm + i] << 8; + m += handSlot[COLOR - stm + (i & 15)] << 8; // force type to unpromoted before taking from hand + if(i > 15) m += 11; } else { sscanf(s, "%c%d%c%d%c", &f2, &r2, &f, &r, &prom); f -= 'a'; f2 -= 'a'; r--, r2--;