From 19fb94c81f006ac504fdb3bf70ed34985de702cd Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sat, 14 Apr 2012 13:27:48 +0200 Subject: [PATCH] Suppress testing for availability in bughouse drops Give up on testing legality of bughouse drop moves; this only causes problems, because the move list sent by the ICS is not accompanied by holdings updates. So XBoard parses it thinking the holdings are empty, making every drop move an ImpossibleMove. Bughouse can only be played on ICS, and we might as well trust the ICS that it will only pass us legal moves. A user should not be able to enter illegal drops; unavailable pieces cannot be grabbed from the holdings, and typing is diverted to the ICS directly (which would reject the illegal drop without XBoard even knowing about it). Also improve switching to bh/zh, based on drop move in initial board. --- backend.c | 5 ++++- moves.c | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/backend.c b/backend.c index 265a55c..bc25c5f 100644 --- a/backend.c +++ b/backend.c @@ -2446,6 +2446,7 @@ VariantSwitch (Board board, VariantClass newVariant) board[i][j+newHoldingsWidth-gameInfo.holdingsWidth] = board[i][j]; } + board[HOLDINGS_SET] = 0; gameInfo.boardWidth = newWidth; gameInfo.boardHeight = newHeight; gameInfo.holdingsWidth = newHoldingsWidth; @@ -4313,6 +4314,7 @@ ParseBoard12 (char *string) } if (gameInfo.boardHeight != ranks || gameInfo.boardWidth != files || + move_str[1] == '@' && !gameInfo.holdingsWidth || weird && (int)gameInfo.variant < (int)VariantShogi) { /* [HGM] We seem to have switched variant unexpectedly * Try to guess new variant from board size @@ -4322,7 +4324,8 @@ ParseBoard12 (char *string) if(ranks == 10 && files == 9) newVariant = VariantXiangqi; else if(ranks == 8 && files == 12) newVariant = VariantCourier; else if(ranks == 9 && files == 9) newVariant = VariantShogi; else - if(!weird) newVariant = VariantNormal; + if(ranks == 10 && files == 10) newVariant = VariantGrand; else + if(!weird) newVariant = move_str[1] == '@' ? VariantCrazyhouse : VariantNormal; VariantSwitch(boards[currentMove], newVariant); /* temp guess */ /* Get a move list just to see the header, which will tell us whether this is really bug or zh */ diff --git a/moves.c b/moves.c index 1c4fe51..a458a84 100644 --- a/moves.c +++ b/moves.c @@ -1053,7 +1053,8 @@ LegalDrop (Board board, int flags, ChessSquare piece, int rt, int ft) if(appData.debugMode) fprintf(debugFP, "LegalDrop: %d @ %d,%d)\n", piece, ft, rt); if(board[rt][ft] != EmptySquare) return ImpossibleMove; // must drop to empty square n = PieceToNumber(piece); - if(gameInfo.holdingsWidth == 0 || (flags & F_WHITE_ON_MOVE ? board[n][BOARD_WIDTH-1] : board[BOARD_HEIGHT-1-n][0]) != piece) + if((gameInfo.holdingsWidth == 0 || (flags & F_WHITE_ON_MOVE ? board[n][BOARD_WIDTH-1] : board[BOARD_HEIGHT-1-n][0]) != piece) + && gameInfo.variant != VariantBughouse) // in bughouse we don't check for availability, because ICS doesn't always tell us return ImpossibleMove; // piece not available if(gameInfo.variant == VariantShogi) { // in Shogi lots of drops are forbidden! if((piece == WhitePawn || piece == WhiteQueen) && rt == BOARD_HEIGHT-1 || -- 1.7.0.4