From: H.G. Muller Date: Mon, 4 Oct 2010 06:21:19 +0000 (+0200) Subject: Make Shogi promotion zone board-size dependent X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=e1156ce1ba68e4c89a7bdb63f388840463002954;p=xboard.git Make Shogi promotion zone board-size dependent In stead of using a fixed size of 3 ranks, we use BOARD_HEIGHT/3, which would translate to 1 rank for mini-Shogi (5x5) and 2 ranks for Judgkin's Shogi (6x6), which are indeed what these variants need. --- diff --git a/backend.c b/backend.c index d539198..dc075ff 100644 --- a/backend.c +++ b/backend.c @@ -5585,7 +5585,7 @@ HasPromotionChoice(int fromX, int fromY, int toX, int toY, char *promoChoice) piece = boards[currentMove][fromY][fromX]; if(gameInfo.variant == VariantShogi) { - promotionZoneSize = 3; + promotionZoneSize = BOARD_HEIGHT/3; highestPromotingPiece = (int)WhiteFerz; } else if(gameInfo.variant == VariantMakruk) { promotionZoneSize = 3; diff --git a/moves.c b/moves.c index 3e58f42..2069b9d 100644 --- a/moves.c +++ b/moves.c @@ -1128,7 +1128,7 @@ ChessMove LegalityTest(board, flags, rf, ff, rt, ft, promoChar) cl.kind = IllegalMove; else if(flags & F_WHITE_ON_MOVE) { if( (int) piece < (int) WhiteWazir && - (rf > BOARD_HEIGHT-4 || rt > BOARD_HEIGHT-4) ) { + (rf >= BOARD_HEIGHT-(BOARD_HEIGHT/3) || rt >= BOARD_HEIGHT-(BOARD_HEIGHT/3)) ) { if( (piece == WhitePawn || piece == WhiteQueen) && rt > BOARD_HEIGHT-2 || piece == WhiteKnight && rt > BOARD_HEIGHT-3) /* promotion mandatory */ cl.kind = promoChar == '=' ? IllegalMove : WhitePromotionKnight; @@ -1138,7 +1138,7 @@ ChessMove LegalityTest(board, flags, rf, ff, rt, ft, promoChar) } else cl.kind = (promoChar == NULLCHAR || promoChar == 'x' || promoChar == '=') ? NormalMove : IllegalMove; } else { - if( (int) piece < (int) BlackWazir && (rf < 3 || rt < 3) ) { + if( (int) piece < (int) BlackWazir && (rf < BOARD_HEIGHT/3 || rt < BOARD_HEIGHT/3) ) { if( (piece == BlackPawn || piece == BlackQueen) && rt < 1 || piece == BlackKnight && rt < 2 ) /* promotion obligatory */ cl.kind = promoChar == '=' ? IllegalMove : BlackPromotionKnight; @@ -1326,7 +1326,7 @@ void Disambiguate(board, flags, closure) closure->kind = IllegalMove; else if(flags & F_WHITE_ON_MOVE) { if( (int) piece < (int) WhiteWazir && - (closure->rf > BOARD_HEIGHT-4 || closure->rt > BOARD_HEIGHT-4) ) { + (closure->rf >= BOARD_HEIGHT-(BOARD_HEIGHT/3) || closure->rt >= BOARD_HEIGHT-(BOARD_HEIGHT/3)) ) { if( (piece == WhitePawn || piece == WhiteQueen) && closure->rt > BOARD_HEIGHT-2 || piece == WhiteKnight && closure->rt > BOARD_HEIGHT-3) /* promotion mandatory */ closure->kind = c == '=' ? IllegalMove : WhitePromotionKnight; @@ -1336,7 +1336,7 @@ void Disambiguate(board, flags, closure) } else closure->kind = (c == NULLCHAR || c == 'x' || c == '=') ? NormalMove : IllegalMove; } else { - if( (int) piece < (int) BlackWazir && (closure->rf < 3 || closure->rt < 3) ) { + if( (int) piece < (int) BlackWazir && (closure->rf < BOARD_HEIGHT/3 || closure->rt < BOARD_HEIGHT/3) ) { if( (piece == BlackPawn || piece == BlackQueen) && closure->rt < 1 || piece == BlackKnight && closure->rt < 2 ) /* promotion obligatory */ closure->kind = c == '=' ? IllegalMove : BlackPromotionKnight; @@ -1594,7 +1594,7 @@ ChessMove CoordsToAlgebraic(board, flags, rf, ff, rt, ft, promoChar, out) /* [HGM] in Shogi non-pawns can promote */ if(flags & F_WHITE_ON_MOVE) { if( (int) cl.piece < (int) WhiteWazir && - (rf > BOARD_HEIGHT-4 || rt > BOARD_HEIGHT-4) ) { + (rf >= BOARD_HEIGHT-(BOARD_HEIGHT/3) || rt >= BOARD_HEIGHT-(BOARD_HEIGHT/3)) ) { if( (piece == WhitePawn || piece == WhiteQueen) && rt > BOARD_HEIGHT-2 || piece == WhiteKnight && rt > BOARD_HEIGHT-3) /* promotion mandatory */ cl.kind = promoChar == '=' ? IllegalMove : WhitePromotionKnight; @@ -1603,7 +1603,7 @@ ChessMove CoordsToAlgebraic(board, flags, rf, ff, rt, ft, promoChar, out) } else cl.kind = (promoChar == NULLCHAR || promoChar == 'x' || promoChar == '=') ? NormalMove : IllegalMove; } else { - if( (int) cl.piece < (int) BlackWazir && (rf < 3 || rt < 3) ) { + if( (int) cl.piece < (int) BlackWazir && (rf < BOARD_HEIGHT/3 || rt < BOARD_HEIGHT/3) ) { if( (piece == BlackPawn || piece == BlackQueen) && rt < 1 || piece == BlackKnight && rt < 2 ) /* promotion obligatory */ cl.kind = promoChar == '=' ? IllegalMove : BlackPromotionKnight;