From b0878c4bb13c5ba03f6defe11f903fa07247b718 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Mon, 11 Oct 2010 09:13:59 +0200 Subject: [PATCH] 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. --- lasker-2.2.3/src/movecheck.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) 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; -- 1.7.0.4