X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=5fb842c22aaeb1e96c0dd22c016a785c4ee1d6f9;hb=f9fe58c6ea5c0938364cd9bd0b434ee66e0f7272;hp=6cba81545d475c4eb0d54001d46e7fa9009d9286;hpb=414a2914d0c5fd2ac5ee27f514346716f1b892b2;p=xboard.git diff --git a/backend.c b/backend.c index 6cba815..5fb842c 100644 --- a/backend.c +++ b/backend.c @@ -5158,6 +5158,12 @@ UserMoveTest(fromX, fromY, toX, toY, promoChar) fprintf(debugFP, "Got premove: fromX %d," "fromY %d, toX %d, toY %d\n", fromX, fromY, toX, toY); + if(!WhiteOnMove(currentMove) && gotPremove == 1) { + // [HGM] race: we must have been hit by an opponent move from the ICS while preparing the premove + if (appData.debugMode) + fprintf(debugFP, "Execute as normal move\n"); + gotPremove = 0; break; + } } return ImpossibleMove; } @@ -5179,6 +5185,12 @@ UserMoveTest(fromX, fromY, toX, toY, promoChar) fprintf(debugFP, "Got premove: fromX %d," "fromY %d, toX %d, toY %d\n", fromX, fromY, toX, toY); + if(WhiteOnMove(currentMove) && gotPremove == 1) { + // [HGM] race: we must have been hit by an opponent move from the ICS while preparing the premove + if (appData.debugMode) + fprintf(debugFP, "Execute as normal move\n"); + gotPremove = 0; break; + } } return ImpossibleMove; } @@ -6378,6 +6390,29 @@ if(appData.debugMode) fprintf(debugFP, "nodes = %d, %lld\n", (int) programStats. } #endif if (pausing) PauseEvent(); + if(appData.forceIllegal) { + // [HGM] illegal: machine refused move; force position after move into it + SendToProgram("force\n", cps); + if(!cps->useSetboard) { // hideous kludge on kludge, because SendBoard sucks. + // we have a real problem now, as SendBoard will use the a2a3 kludge + // when black is to move, while there might be nothing on a2 or black + // might already have the move. So send the board as if white has the move. + // But first we must change the stm of the engine, as it refused the last move + SendBoard(cps, 0); // always kludgeless, as white is to move on boards[0] + if(WhiteOnMove(forwardMostMove)) { + SendToProgram("a7a6\n", cps); // for the engine black still had the move + SendBoard(cps, forwardMostMove); // kludgeless board + } else { + SendToProgram("a2a3\n", cps); // for the engine white still had the move + CopyBoard(boards[forwardMostMove+1], boards[forwardMostMove]); + SendBoard(cps, forwardMostMove+1); // kludgeless board + } + } else SendBoard(cps, forwardMostMove); // FEN case, also sets stm properly + if(gameMode == MachinePlaysWhite || gameMode == MachinePlaysBlack || + gameMode == TwoMachinesPlay) + SendToProgram("go\n", cps); + return; + } else if (gameMode == PlayFromGameFile) { /* Stop reading this game file */ gameMode = EditGame;