Fix confinement of Advisor in Xiangqi
authorH.G.Muller <hgm@hgm-xboard.(none)>
Thu, 21 Apr 2016 20:47:18 +0000 (22:47 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Thu, 21 Apr 2016 20:47:18 +0000 (22:47 +0200)
Ever since the move-generator rewrite the Advisor could leave the Palace!
Now it can only move in XQ as a normal Ferz when on the board axis, and
everywhere els it can only move to the axis one square from the edge.
This does not generalize in a natural way to larger boards or larger
Palaces.

moves.c

diff --git a/moves.c b/moves.c
index cc3343b..a5ec955 100644 (file)
--- a/moves.c
+++ b/moves.c
@@ -1179,6 +1179,12 @@ GenPseudoLegal (Board board, int flags, MoveCallback callback, VOIDSTAR closure,
 
             case WhiteFerz:
             case BlackFerz:
+               if(gameInfo.variant == VariantXiangqi && ff != BOARD_WIDTH>>1) {
+                   int rt = (piece == BlackFerz ? BOARD_HEIGHT-2 : 1);
+                   int ft = BOARD_WIDTH>>1;
+                   if(!SameColor(board[rf][ff], board[rt][ft]))
+                       callback(board, flags, NormalMove, rf, ff, rt, ft, closure);
+               } else
                 /* [HGM] support Shatranj pieces */
                Ferz(board, flags, rf, ff, callback, closure);
                break;