machineMove, fromX+AAA, fromY+ONE, toX+AAA, toY+ONE, 0);\r
GameEnds(machineWhite ? BlackWins : WhiteWins,\r
buf1, GE_XBOARD);\r
+ return;\r
} else if(gameInfo.variant != VariantFischeRandom && gameInfo.variant != VariantCapaRandom)\r
/* [HGM] Kludge to handle engines that send FRC-style castling\r
when they shouldn't (like TSCP-Gothic) */\r
int k, count = 0, epFile = epStatus[forwardMostMove]; static int bare = 1;\r
if(gameInfo.holdingsSize == 0 || gameInfo.variant == VariantSuper || gameInfo.variant == VariantGreat) {\r
\r
- if(appData.testLegality)\r
- // don't wait for engine to announce game end if we can judge ourselves\r
- switch (MateTest(boards[forwardMostMove],\r
- PosFlags(forwardMostMove), epFile,\r
- castlingRights[forwardMostMove]) ) {\r
- case MT_NONE:\r
- case MT_CHECK:\r
- default:\r
- break;\r
- case MT_STALEMATE:\r
- epStatus[forwardMostMove] = EP_STALEMATE;\r
- if(appData.checkMates) {\r
- SendMoveToProgram(forwardMostMove-1, cps->other); /* make sure opponent gets to see move */\r
- ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/\r
- if(gameInfo.variant == VariantLosers || gameInfo.variant == VariantSuicide\r
- || gameInfo.variant == VariantGiveaway) // [HGM] losers:\r
- GameEnds( WhiteOnMove(forwardMostMove) ? WhiteWins : BlackWins, // stalemated side wins!\r
- "Xboard adjudication: Stalemate", GE_XBOARD );\r
- else\r
- GameEnds( GameIsDrawn, "Xboard adjudication: Stalemate", GE_XBOARD );\r
- return;\r
- }\r
- break;\r
- case MT_CHECKMATE:\r
- epStatus[forwardMostMove] = EP_CHECKMATE;\r
- if(appData.checkMates) {\r
- SendMoveToProgram(forwardMostMove-1, cps->other); /* make sure opponent gets to see move */\r
- ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/\r
- GameEnds( WhiteOnMove(forwardMostMove) != (gameInfo.variant == VariantLosers) // [HGM] losers:\r
- ? BlackWins : WhiteWins, // reverse the result ( A!=1 is !A for a boolean)\r
- "Xboard adjudication: Checkmate", GE_XBOARD );\r
- return;\r
- }\r
- break;\r
- }\r
-\r
if( appData.testLegality )\r
{ /* [HGM] Some more adjudications for obstinate engines */\r
int NrWN=0, NrBN=0, NrWB=0, NrBB=0, NrWR=0, NrBR=0,\r
NrPieces=0, NrPawns=0, PawnAdvance=0, i, j;\r
static int moveCount = 6;\r
\r
- /* First absolutely insufficient mating material. Count what is on board. */\r
+ /* Count what is on board. */\r
for(i=0; i<BOARD_HEIGHT; i++) for(j=BOARD_LEFT; j<BOARD_RGHT; j++)\r
{ ChessSquare p = boards[forwardMostMove][i][j];\r
int m=i;\r
}\r
}\r
\r
+ /* Some material-based adjudications that have to be made before stalemate test */\r
if(gameInfo.variant == VariantAtomic && NrK < 2) {\r
// [HGM] atomic: stm must have lost his King on previous move, as destroying own K is illegal\r
epStatus[forwardMostMove] = EP_CHECKMATE; // make claimable as if stm is checkmated\r
} else bare = 1;\r
\r
\r
+ // don't wait for engine to announce game end if we can judge ourselves\r
+ switch (MateTest(boards[forwardMostMove],\r
+ PosFlags(forwardMostMove), epFile,\r
+ castlingRights[forwardMostMove]) ) {\r
+ case MT_NONE:\r
+ case MT_CHECK:\r
+ default:\r
+ break;\r
+ case MT_STALEMATE:\r
+ if(epStatus[forwardMostMove] != EP_CHECKMATE) // [HGM] spare win through baring or K-capt\r
+ epStatus[forwardMostMove] = EP_STALEMATE;\r
+ if(appData.checkMates) {\r
+ SendMoveToProgram(forwardMostMove-1, cps->other); /* make sure opponent gets to see move */\r
+ ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/\r
+ if(gameInfo.variant == VariantLosers || gameInfo.variant == VariantSuicide\r
+ || gameInfo.variant == VariantGiveaway) // [HGM] losers:\r
+ GameEnds( WhiteOnMove(forwardMostMove) ? WhiteWins : BlackWins, // stalemated side wins!\r
+ "Xboard adjudication: Stalemate", GE_XBOARD );\r
+ else\r
+ GameEnds( GameIsDrawn, "Xboard adjudication: Stalemate", GE_XBOARD );\r
+ return;\r
+ }\r
+ break;\r
+ case MT_CHECKMATE:\r
+ epStatus[forwardMostMove] = EP_CHECKMATE;\r
+ if(appData.checkMates) {\r
+ SendMoveToProgram(forwardMostMove-1, cps->other); /* make sure opponent gets to see move */\r
+ ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/\r
+ GameEnds( WhiteOnMove(forwardMostMove) != (gameInfo.variant == VariantLosers) // [HGM] losers:\r
+ ? BlackWins : WhiteWins, // reverse the result ( A!=1 is !A for a boolean)\r
+ "Xboard adjudication: Checkmate", GE_XBOARD );\r
+ return;\r
+ }\r
+ break;\r
+ }\r
+\r
+ /* Next absolutely insufficient mating material. */\r
if( NrPieces == 2 || gameInfo.variant != VariantXiangqi && \r
gameInfo.variant != VariantShatranj && // [HGM] baring will remain possible\r
(NrPieces == 3 && NrWN+NrBN+NrWB+NrBB == 1 ||\r