From: H.G. Muller Date: Mon, 11 Oct 2010 07:13:59 +0000 (+0200) Subject: Test Legality of Shogi promotions X-Git-Url: http://winboard.nl/cgi-bin?p=capablanca.git;a=commitdiff_plain;h=b0878c4bb13c5ba03f6defe11f903fa07247b718;hp=2255d9155bc3e24104ce7a30edeff78fd6b4d53e Test Legality of Shogi promotions The old code would allow any drop, except Pawns on first and last rank, which is actually too restrictive for Shogi (which does allow back-rank Pawn drops). Only thing still missing is Pawn drop with mate. --- diff --git a/lasker-2.2.3/src/movecheck.c b/lasker-2.2.3/src/movecheck.c index c0dd853..1f6d69b 100644 --- a/lasker-2.2.3/src/movecheck.c +++ b/lasker-2.2.3/src/movecheck.c @@ -1303,6 +1303,21 @@ int legal_move(struct game_state_t * gs, return 0; if (gs->board[tFile][tRank] != NOPIECE) return 0; + if (gs->promoType == 3) { // Shogi + int r; + switch(move_piece) { + case PAWN: // check for own Pawn in same file + for(r=0; rranks; r++) if(gs->board[tFile][r] == (gs->onMove|PAWN)) return 0; + case LANCE: // Pawns and Lances not on last rank + if(gs->onMove == WHITE && tRank >= gs->ranks-1) return 0; + if(gs->onMove == BLACK && tRank < 1) return 0; + break; + case HONORABLEHORSE: // Knights at least two ranks from edge + if(gs->onMove == WHITE && tRank >= gs->ranks-2) return 0; + if(gs->onMove == BLACK && tRank < 2) return 0; + default: ; + } + } else if (move_piece == PAWN && (tRank == 0 || tRank == gs->ranks-1)) return 0; return 1;