From bf368bef696bee3555a370ac8ff88418e1f5c498 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Mon, 5 Oct 2009 20:01:53 -0700 Subject: [PATCH] new forceIllegalMoves option The -forceIllegalMoves option uses setboard or edit to force a position when an engine refuses the move leading to it by an "Illegal Move" message. Especially for engines using the edit command this was a bit tricky, because of the a2a3 kludge to avoid using the white and black commands. --- backend.c | 23 +++++++++++++++++++++++ common.h | 1 + winboard/winboard.c | 1 + 3 files changed, 25 insertions(+), 0 deletions(-) diff --git a/backend.c b/backend.c index 304acc2..5fb842c 100644 --- a/backend.c +++ b/backend.c @@ -6390,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; diff --git a/common.h b/common.h index fb218bc..83c6837 100644 --- a/common.h +++ b/common.h @@ -601,6 +601,7 @@ typedef struct { char *fenOverride1; char *fenOverride2; Boolean keepAlive; /* [HGM] alive */ + Boolean forceIllegal;/*[HGM] illegal */ } AppData, *AppDataPtr; /* [AS] PGN tags (for showing in the game list) */ diff --git a/winboard/winboard.c b/winboard/winboard.c index 3b2dd29..bbd8563 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -1339,6 +1339,7 @@ ArgDescriptor argDescriptors[] = { { "secondNeedsNoncompliantFEN", ArgString, (LPVOID) &appData.fenOverride2, FALSE }, { "keepAlive", ArgInt, (LPVOID) &appData.keepAlive, FALSE }, { "icstype", ArgInt, (LPVOID) &ics_type, FALSE }, + { "forceIllegalMoves", ArgTrue, (LPVOID) &appData.forceIllegal, FALSE }, #ifdef ZIPPY { "zippyTalk", ArgBoolean, (LPVOID) &appData.zippyTalk, FALSE }, -- 1.7.0.4