From e6bbc0609a8fd2080b6274af55186a431b851210 Mon Sep 17 00:00:00 2001 From: "H.G. Muller" Date: Sun, 31 Oct 2010 13:08:52 +0100 Subject: [PATCH] Augment moves of some fairy pieces To get better disambiguation in variants that have to be played with legality testing off, the Elephant is given also one-step moves (making it a so-called Modern Elephant) in -variant fairy and great. The Dragon King (Crowned Rook), which had no moves defined for it outside Shogi at all, has been given Rook moves plus an orthogonal 2-jump, so that it can get SAN moves when used as Dababba or Short Rook. (Illegal moves currently aways force long algebraic notation...) --- moves.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/moves.c b/moves.c index 89af9a05..d6671138 100644 --- a/moves.c +++ b/moves.c @@ -415,6 +415,13 @@ void GenPseudoLegal(board, flags, callback, closure) && ( gameInfo.variant != VariantXiangqi || board[rf+rs][ff+fs] == EmptySquare && (2*rf < BOARD_HEIGHT) == (2*rt < BOARD_HEIGHT) ) + && !SameColor(board[rf][ff], board[rt][ft])) + callback(board, flags, NormalMove, + rf, ff, rt, ft, closure); + if(gameInfo.variant != VariantFairy && gameInfo.variant != VariantGreat) continue; + rt = rf + rs; // in unknown variant we assume Modern Elephant, which can also do one step + ft = ff + fs; + if (!(rt < 0 || rt >= BOARD_HEIGHT || ft < BOARD_LEFT || ft >= BOARD_RGHT) && !SameColor(board[rf][ff], board[rt][ft])) callback(board, flags, NormalMove, rf, ff, rt, ft, closure); @@ -477,6 +484,19 @@ void GenPseudoLegal(board, flags, callback, closure) } break; + /* Make Dragon-King Dababba & Rook-like outside Shogi, for better disambiguation in variant Fairy */ + case WhiteDragon: + case BlackDragon: + for (d = 0; d <= 1; d++) // Dababba moves that Rook cannot do + for (s = -2; s <= 2; s += 4) { + rt = rf + s * d; + ft = ff + s * (1 - d); + if (rt < 0 || rt >= BOARD_HEIGHT || ft < BOARD_LEFT || ft >= BOARD_RGHT || board[rf+rt>>1][ff+ft>>1] == EmptySquare) continue; + if (SameColor(board[rf][ff], board[rt][ft])) continue; + callback(board, flags, NormalMove, rf, ff, rt, ft, closure); + } + goto doRook; + /* Shogi Dragon King has to continue as Ferz after Rook moves */ case SHOGI WhiteDragon: case SHOGI BlackDragon: @@ -492,6 +512,7 @@ void GenPseudoLegal(board, flags, callback, closure) case SHOGI BlackRook: case WhiteRook: case BlackRook: + doRook: for (d = 0; d <= 1; d++) for (s = -1; s <= 1; s += 2) for (i = 1;; i++) { -- 2.17.1