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.
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; r<gs->ranks; 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;