From: H.G.Muller Date: Thu, 5 Feb 2015 19:09:53 +0000 (+0100) Subject: Castle with nearest rather than corner piece X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=ced64ba7e2ff09bc951a570bf9d27d4db83584b0;p=xboard.git Castle with nearest rather than corner piece An oversized sideway King step is recognized as castling, but instead of using the piece closest to the board edge on that rank (ignoring dark squares) we now use the piece that the King is looking at in that direction. This fixes castling in Omega Chess. --- diff --git a/backend.c b/backend.c index dbfb234..670eb4b 100644 --- a/backend.c +++ b/backend.c @@ -10044,19 +10044,19 @@ ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board) } else if (board[fromY][fromX] == king && fromX != BOARD_LEFT && fromX != BOARD_RGHT-1 // [HGM] cylinder */ && toY == fromY && toX > fromX+1) { + for(rookX=fromX+1; board[toY][rookX] == EmptySquare && rookX < BOARD_RGHT-1; rookX++); // castle with nearest piece + board[fromY][toX-1] = board[fromY][rookX]; + board[fromY][rookX] = EmptySquare; board[fromY][fromX] = EmptySquare; board[toY][toX] = king; - for(rookX=BOARD_RGHT-1; board[toY][rookX] == DarkSquare && rookX > toX + 1; rookX--); - board[toY][toX-1] = board[fromY][rookX]; - board[fromY][rookX] = EmptySquare; } else if (board[fromY][fromX] == king && fromX != BOARD_LEFT && fromX != BOARD_RGHT-1 // [HGM] cylinder */ && toY == fromY && toX < fromX-1) { + for(rookX=fromX-1; board[toY][rookX] == EmptySquare && rookX > 0; rookX--); // castle with nearest piece + board[fromY][toX+1] = board[fromY][rookX]; + board[fromY][rookX] = EmptySquare; board[fromY][fromX] = EmptySquare; board[toY][toX] = king; - for(rookX=BOARD_LEFT; board[toY][rookX] == DarkSquare && rookX < toX - 1; rookX++); - board[toY][toX+1] = board[fromY][rookX]; - board[fromY][rookX] = EmptySquare; } else if ((board[fromY][fromX] == WhitePawn && gameInfo.variant != VariantXiangqi || board[fromY][fromX] == WhiteLance && gameInfo.variant != VariantSuper && gameInfo.variant != VariantChu) && toY >= BOARD_HEIGHT-promoRank && promoChar // defaulting to Q is done elsewhere @@ -10095,19 +10095,19 @@ ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board) } else if (board[fromY][fromX] == king && fromX != BOARD_LEFT && fromX != BOARD_RGHT-1 // [HGM] cylinder */ && toY == fromY && toX > fromX+1) { + for(rookX=toX+1; board[toY][rookX] == EmptySquare && rookX < BOARD_RGHT - 1; rookX++); + board[fromY][toX-1] = board[fromY][rookX]; + board[fromY][rookX] = EmptySquare; board[fromY][fromX] = EmptySquare; board[toY][toX] = king; - for(rookX=BOARD_RGHT-1; board[toY][rookX] == DarkSquare && rookX > toX + 1; rookX--); - board[toY][toX-1] = board[fromY][rookX]; - board[fromY][rookX] = EmptySquare; } else if (board[fromY][fromX] == king && fromX != BOARD_LEFT && fromX != BOARD_RGHT-1 // [HGM] cylinder */ && toY == fromY && toX < fromX-1) { + for(rookX=toX-1; board[toY][rookX] == EmptySquare && rookX > 0; rookX--); + board[fromY][toX+1] = board[fromY][rookX]; + board[fromY][rookX] = EmptySquare; board[fromY][fromX] = EmptySquare; board[toY][toX] = king; - for(rookX=BOARD_LEFT; board[toY][rookX] == DarkSquare && rookX < toX - 1; rookX++); - board[toY][toX+1] = board[fromY][rookX]; - board[fromY][rookX] = EmptySquare; } else if (fromY == 7 && fromX == 3 && board[fromY][fromX] == BlackKing && toY == 7 && toX == 5) {