From 2255d9155bc3e24104ce7a30edeff78fd6b4d53e Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Mon, 11 Oct 2010 08:57:39 +0200 Subject: [PATCH] Handle Shogi promotions on SAN moves --- lasker-2.2.3/src/algcheck.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/lasker-2.2.3/src/algcheck.c b/lasker-2.2.3/src/algcheck.c index 065a859..cdc97b2 100644 --- a/lasker-2.2.3/src/algcheck.c +++ b/lasker-2.2.3/src/algcheck.c @@ -222,6 +222,31 @@ static void add_promotion(struct game_state_t *gs, const char *mstr, struct move return; } + if(gs->promoType == 3) { // handle Shogi promotions + piece = gs->board[mt->fromFile][mt->fromRank]; + if(colorval(piece) == WHITE && mt->fromRank < gs->ranks - gs->ranks/3 + && mt->toRank < gs->ranks - gs->ranks/3 ) return; + if(colorval(piece) == BLACK && mt->fromRank >= gs->ranks/3 + && mt->toRank >= gs->ranks/3 ) return; + switch(piecetype(piece)) { + case PAWN: + case LANCE: + case HONORABLEHORSE: + case SILVER: + if(s[1] != '+' && s[1] != '^' && s[1] != 'G' && s[1] != 'g') return; + piece = GOLD; break; + case BISHOP: + if(s[1] != '+' && s[1] != '^' && s[1] != 'H' && s[1] != 'h') return; + piece = DRAGONHORSE; break; + case ROOK: + if(s[1] != '+' && s[1] != '^' && s[1] != 'D' && s[1] != 'd') return; + piece = DRAGONKING; break; + default: return; // others do not promote, so ignore + } + mt->piecePromotionTo = piece | colorval(gs->board[mt->fromFile][mt->fromRank]); + return; + } + if (piecetype(gs->board[mt->fromFile][mt->fromRank]) != PAWN) { return; } -- 1.7.0.4