From: H.G.Muller Date: Thu, 8 Oct 2020 14:17:38 +0000 (+0200) Subject: Fix diagonal moves Janggi in opponent Palace X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=a0f60e2cab71ed60f5329cc0f7fa4376fcd219db;p=xboard.git Fix diagonal moves Janggi in opponent Palace The test for being in Palace should not refer to the Palace of your own color, but to the Palace on your current board half. Also, Cannons should not be able to jump over or capture each other inside the Palace. --- diff --git a/moves.c b/moves.c index f60ec7a..0adace5 100644 --- a/moves.c +++ b/moves.c @@ -779,15 +779,18 @@ PalaceDiags (Board board, int flags, int rf, int ff, int isRook, MoveCallback ca { // Janggi diagonal palace moves int piece = board[rf][ff]; int middle = BOARD_WIDTH/2; - int palace = (piece < BlackPawn ? 1 : BOARD_HEIGHT-2); + int palace = (rf < 3 ? 1 : BOARD_HEIGHT-2); if(ff == middle) { if(rf == palace && isRook) Ferz(board, flags, rf, ff, callback, closure); } else if((ff == middle+1 || ff == middle-1) && (rf == palace+1 || rf == palace-1)) { // Palace corner int rt = 2*palace - rf, ft = 2*middle - ff; // reflect - if((board[palace][middle] == EmptySquare) == isRook && !SameColor(piece, board[rt][ft])) - callback(board, flags, NormalMove, rf, ff, rt, ft, closure); - if(isRook && !SameColor(piece, board[palace][middle])) + ChessSquare center = board[palace][middle]; + if(isRook && !SameColor(piece, center)) callback(board, flags, NormalMove, rf, ff, palace, middle, closure); + if(center == WhiteCannon || center == BlackCannon) return; + if((center == EmptySquare) == isRook && !SameColor(piece, board[rt][ft]) + && piece + board[rt][ft] != WhiteCannon + BlackCannon) + callback(board, flags, NormalMove, rf, ff, rt, ft, closure); } }