Board boards[MAX_MOVES];
/* [HGM] Following 7 needed for accurate legality tests: */
- signed char epStatus[MAX_MOVES];
- signed char castlingRights[MAX_MOVES][BOARD_SIZE]; // stores files for pieces with castling rights or -1
- signed char castlingRank[BOARD_SIZE]; // and corresponding ranks
- signed char initialRights[BOARD_SIZE], FENcastlingRights[BOARD_SIZE], fileRights[BOARD_SIZE];
+ signed char castlingRank[BOARD_FILES]; // and corresponding ranks
+ signed char initialRights[BOARD_FILES];
int nrCastlingRights; // For TwoKings, or to implement castling-unknown status
int initialRulePlies, FENrulePlies;
- char FENepStatus;
FILE *serverMoves = NULL; // next two for broadcasting (/serverMoves option)
-int loadFlag = 0;
+int loadFlag = 0;
int shuffleOpenings;
int mute; // mute all sounds
BlackWazir, BlackFerz, BlackAlfil, BlackKnight, BlackRook }
};
- ChessSquare CapablancaArray[2][BOARD_SIZE] = {
+ ChessSquare CapablancaArray[2][BOARD_FILES] = {
- { WhiteRook, WhiteKnight, WhiteAngel, WhiteBishop, WhiteQueen,
+ { WhiteRook, WhiteKnight, WhiteAngel, WhiteBishop, WhiteQueen,
WhiteKing, WhiteBishop, WhiteMarshall, WhiteKnight, WhiteRook },
- { BlackRook, BlackKnight, BlackAngel, BlackBishop, BlackQueen,
+ { BlackRook, BlackKnight, BlackAngel, BlackBishop, BlackQueen,
BlackKing, BlackBishop, BlackMarshall, BlackKnight, BlackRook }
};
- ChessSquare GreatArray[2][BOARD_SIZE] = {
+ ChessSquare GreatArray[2][BOARD_FILES] = {
- { WhiteDragon, WhiteKnight, WhiteAlfil, WhiteGrasshopper, WhiteKing,
+ { WhiteDragon, WhiteKnight, WhiteAlfil, WhiteGrasshopper, WhiteKing,
WhiteSilver, WhiteCardinal, WhiteAlfil, WhiteKnight, WhiteDragon },
- { BlackDragon, BlackKnight, BlackAlfil, BlackGrasshopper, BlackKing,
+ { BlackDragon, BlackKnight, BlackAlfil, BlackGrasshopper, BlackKing,
BlackSilver, BlackCardinal, BlackAlfil, BlackKnight, BlackDragon },
};
- ChessSquare JanusArray[2][BOARD_SIZE] = {
+ ChessSquare JanusArray[2][BOARD_FILES] = {
- { WhiteRook, WhiteAngel, WhiteKnight, WhiteBishop, WhiteKing,
+ { WhiteRook, WhiteAngel, WhiteKnight, WhiteBishop, WhiteKing,
WhiteQueen, WhiteBishop, WhiteKnight, WhiteAngel, WhiteRook },
- { BlackRook, BlackAngel, BlackKnight, BlackBishop, BlackKing,
+ { BlackRook, BlackAngel, BlackKnight, BlackBishop, BlackKing,
BlackQueen, BlackBishop, BlackKnight, BlackAngel, BlackRook }
};
#ifdef GOTHIC
- ChessSquare GothicArray[2][BOARD_SIZE] = {
+ ChessSquare GothicArray[2][BOARD_FILES] = {
- { WhiteRook, WhiteKnight, WhiteBishop, WhiteQueen, WhiteMarshall,
+ { WhiteRook, WhiteKnight, WhiteBishop, WhiteQueen, WhiteMarshall,
WhiteKing, WhiteAngel, WhiteBishop, WhiteKnight, WhiteRook },
- { BlackRook, BlackKnight, BlackBishop, BlackQueen, BlackMarshall,
+ { BlackRook, BlackKnight, BlackBishop, BlackQueen, BlackMarshall,
BlackKing, BlackAngel, BlackBishop, BlackKnight, BlackRook }
};
#else // !GOTHIC
#endif // !GOTHIC
#ifdef FALCON
- ChessSquare FalconArray[2][BOARD_SIZE] = {
+ ChessSquare FalconArray[2][BOARD_FILES] = {
- { WhiteRook, WhiteKnight, WhiteBishop, WhiteLance, WhiteQueen,
+ { WhiteRook, WhiteKnight, WhiteBishop, WhiteLance, WhiteQueen,
WhiteKing, WhiteLance, WhiteBishop, WhiteKnight, WhiteRook },
- { BlackRook, BlackKnight, BlackBishop, BlackLance, BlackQueen,
+ { BlackRook, BlackKnight, BlackBishop, BlackLance, BlackQueen,
BlackKing, BlackLance, BlackBishop, BlackKnight, BlackRook }
};
#else // !FALCON
if(gameInfo.variant == VariantKnightmate) { wKing = WhiteUnicorn; bKing = BlackUnicorn; }
for(k=BOARD_LEFT; k<BOARD_RGHT; k++)
- if(board[0][k] == wKing) initialRights[2] = castlingRights[moveNum][2] = k;
+ if(board[0][k] == wKing) initialRights[2] = boards[moveNum][CASTLING][2] = k;
for(k=BOARD_LEFT; k<BOARD_RGHT; k++)
if(board[BOARD_HEIGHT-1][k] == bKing)
- initialRights[5] = castlingRights[moveNum][5] = k;
+ initialRights[5] = boards[moveNum][CASTLING][5] = k;
} else { int r;
- r = castlingRights[moveNum][0] = initialRights[0];
- if(board[0][r] != WhiteRook) castlingRights[moveNum][0] = -1;
- r = castlingRights[moveNum][1] = initialRights[1];
- if(board[0][r] != WhiteRook) castlingRights[moveNum][1] = -1;
- r = castlingRights[moveNum][3] = initialRights[3];
- if(board[BOARD_HEIGHT-1][r] != BlackRook) castlingRights[moveNum][3] = -1;
- r = castlingRights[moveNum][4] = initialRights[4];
- if(board[BOARD_HEIGHT-1][r] != BlackRook) castlingRights[moveNum][4] = -1;
+ r = boards[moveNum][CASTLING][0] = initialRights[0];
+ if(board[0][r] != WhiteRook) boards[moveNum][CASTLING][0] = NoRights;
+ r = boards[moveNum][CASTLING][1] = initialRights[1];
+ if(board[0][r] != WhiteRook) boards[moveNum][CASTLING][1] = NoRights;
+ r = boards[moveNum][CASTLING][3] = initialRights[3];
+ if(board[BOARD_HEIGHT-1][r] != BlackRook) boards[moveNum][CASTLING][3] = NoRights;
+ r = boards[moveNum][CASTLING][4] = initialRights[4];
+ if(board[BOARD_HEIGHT-1][r] != BlackRook) boards[moveNum][CASTLING][4] = NoRights;
/* wildcastle kludge: always assume King has rights */
- r = castlingRights[moveNum][2] = initialRights[2];
- r = castlingRights[moveNum][5] = initialRights[5];
+ r = boards[moveNum][CASTLING][2] = initialRights[2];
+ r = boards[moveNum][CASTLING][5] = initialRights[5];
}
/* [HGM] e.p. rights. Assume that ICS sends file number here? */
- epStatus[moveNum] = double_push == -1 ? EP_NONE : double_push + BOARD_LEFT;
+ boards[moveNum][EP_STATUS] = double_push == -1 ? EP_NONE : double_push + BOARD_LEFT;
-
+
if (ics_getting_history == H_GOT_REQ_HEADER ||
ics_getting_history == H_GOT_UNREQ_HEADER) {
/* This was an initial position from a move list, not
case VariantJanus:
pieces = JanusArray;
gameInfo.boardWidth = 10;
- SetCharTable(pieceToChar, "PNBRQ..JKpnbrq..jk");
+ SetCharTable(pieceToChar, "PNBRQ..JKpnbrq..jk");
nrCastlingRights = 6;
- castlingRights[0][0] = initialRights[0] = BOARD_RGHT-1;
- castlingRights[0][1] = initialRights[1] = BOARD_LEFT;
- castlingRights[0][2] = initialRights[2] =(BOARD_WIDTH-1)>>1;
- castlingRights[0][3] = initialRights[3] = BOARD_RGHT-1;
- castlingRights[0][4] = initialRights[4] = BOARD_LEFT;
- castlingRights[0][5] = initialRights[5] =(BOARD_WIDTH-1)>>1;
+ initialPosition[CASTLING][0] = initialRights[0] = BOARD_RGHT-1;
+ initialPosition[CASTLING][1] = initialRights[1] = BOARD_LEFT;
+ initialPosition[CASTLING][2] = initialRights[2] =(BOARD_WIDTH-1)>>1;
+ initialPosition[CASTLING][3] = initialRights[3] = BOARD_RGHT-1;
+ initialPosition[CASTLING][4] = initialRights[4] = BOARD_LEFT;
+ initialPosition[CASTLING][5] = initialRights[5] =(BOARD_WIDTH-1)>>1;
break;
case VariantFalcon:
pieces = FalconArray;
/* This sets default castling rights from none to normal corners */
/* Variants with other castling rights must set them themselves above */
nrCastlingRights = 6;
-
- castlingRights[0][0] = initialRights[0] = BOARD_RGHT-1;
- castlingRights[0][1] = initialRights[1] = BOARD_LEFT;
- castlingRights[0][2] = initialRights[2] = BOARD_WIDTH>>1;
- castlingRights[0][3] = initialRights[3] = BOARD_RGHT-1;
- castlingRights[0][4] = initialRights[4] = BOARD_LEFT;
- castlingRights[0][5] = initialRights[5] = BOARD_WIDTH>>1;
-
+ initialPosition[CASTLING][0] = initialRights[0] = BOARD_RGHT-1;
+ initialPosition[CASTLING][1] = initialRights[1] = BOARD_LEFT;
+ initialPosition[CASTLING][2] = initialRights[2] = BOARD_WIDTH>>1;
+ initialPosition[CASTLING][3] = initialRights[3] = BOARD_RGHT-1;
+ initialPosition[CASTLING][4] = initialRights[4] = BOARD_LEFT;
+ initialPosition[CASTLING][5] = initialRights[5] = BOARD_WIDTH>>1;
}
if(gameInfo.variant == VariantSuper) Prelude(initialPosition);
}
userOfferedDraw = FALSE;
-
+
/* [HGM] always test for legality, to get promotion info */
moveType = LegalityTest(boards[currentMove], PosFlags(currentMove),
- epStatus[currentMove], castlingRights[currentMove],
fromY, fromX, toY, toX, promoChar);
/* [HGM] but possibly ignore an IllegalMove result */
if (appData.testLegality) {
int fromX, fromY, toX, toY;
/*char*/int promoChar;
{
- char *bookHit = 0;
+ char *bookHit = 0;
- if(appData.debugMode)
- fprintf(debugFP, "moveType 5 = %d, promochar = %x\n", moveType, promoChar);
-
- if((gameInfo.variant == VariantSuper || gameInfo.variant == VariantGreat) && promoChar != NULLCHAR) {
- // [HGM] superchess: suppress promotions to non-available piece
- int k = PieceToNumber(CharToPiece(ToUpper(promoChar)));
- if(WhiteOnMove(currentMove)) {
- if(!boards[currentMove][k][BOARD_WIDTH-2]) return 0;
- } else {
- if(!boards[currentMove][BOARD_HEIGHT-1-k][1]) return 0;
+ if((gameInfo.variant == VariantSuper || gameInfo.variant == VariantGreat) && promoChar != NULLCHAR)
+ {
+ // [HGM] superchess: suppress promotions to non-available piece
+ int k = PieceToNumber(CharToPiece(ToUpper(promoChar)));
+ if(WhiteOnMove(currentMove))
+ {
+ if(!boards[currentMove][k][BOARD_WIDTH-2])
+ return 0;
+ }
+ else
+ {
+ if(!boards[currentMove][BOARD_HEIGHT-1-k][1])
+ return 0;
}
}
-
- /* [HGM] <popupFix> kludge to avoid having to know the exact promotion
- move type in caller when we know the move is a legal promotion */
- if(moveType == NormalMove && promoChar)
- moveType = PromoCharToMoveType(WhiteOnMove(currentMove), promoChar);
-
- /* [HGM] convert drag-and-drop piece drops to standard form */
- if( (fromX == BOARD_LEFT-2 || fromX == BOARD_RGHT+1) && fromY != DROP_RANK ){
- moveType = WhiteOnMove(currentMove) ? WhiteDrop : BlackDrop;
- if(appData.debugMode) fprintf(debugFP, "Drop move %d, curr=%d, x=%d,y=%d, p=%d\n",
- moveType, currentMove, fromX, fromY, boards[currentMove][fromY][fromX]);
- // holdings might not be sent yet in ICS play; we have to figure out which piece belongs here
- if(fromX == 0) fromY = BOARD_HEIGHT-1 - fromY; // black holdings upside-down
- fromX = fromX ? WhitePawn : BlackPawn; // first piece type in selected holdings
- while(PieceToChar(fromX) == '.' || PieceToNumber(fromX) != fromY && fromX != (int) EmptySquare) fromX++;
- fromY = DROP_RANK;
+
+ /* [HGM] <popupFix> kludge to avoid having to know the exact promotion
+ move type in caller when we know the move is a legal promotion */
+ if(moveType == NormalMove && promoChar)
+ moveType = PromoCharToMoveType(WhiteOnMove(currentMove), promoChar);
-
- if(appData.debugMode)
- fprintf(debugFP, "moveType 1 = %d, promochar = %x\n", moveType, promoChar);
-
++
++ /* [HGM] <popupFix> kludge to avoid having to know the exact promotion
++ move type in caller when we know the move is a legal promotion */
++ if(moveType == NormalMove && promoChar)
++ moveType = PromoCharToMoveType(WhiteOnMove(currentMove), promoChar);
++
+ /* [HGM] convert drag-and-drop piece drops to standard form */
- if( fromX == BOARD_LEFT-2 || fromX == BOARD_RGHT+1)
++ if( (fromX == BOARD_LEFT-2 || fromX == BOARD_RGHT+1) && fromY != DROP_RANK )
+ {
+ moveType = WhiteOnMove(currentMove) ? WhiteDrop : BlackDrop;
- if(appData.debugMode)
- fprintf(debugFP, "Drop move %d, curr=%d, x=%d,y=%d, p=%d\n",
- moveType, currentMove, fromX, fromY, boards[currentMove][fromY][fromX]);
- // fromX = boards[currentMove][fromY][fromX];
++ if(appData.debugMode) fprintf(debugFP, "Drop move %d, curr=%d, x=%d,y=%d, p=%d\n",
++ moveType, currentMove, fromX, fromY, boards[currentMove][fromY][fromX]);
+ // holdings might not be sent yet in ICS play; we have to figure out which piece belongs here
- if(fromX == 0)
- fromY = BOARD_HEIGHT-1 - fromY; // black holdings upside-down
-
++ if(fromX == 0) fromY = BOARD_HEIGHT-1 - fromY; // black holdings upside-down
+ fromX = fromX ? WhitePawn : BlackPawn; // first piece type in selected holdings
-
- while(PieceToChar(fromX) == '.' || PieceToNumber(fromX) != fromY && fromX != (int) EmptySquare)
- fromX++;
-
++ while(PieceToChar(fromX) == '.' || PieceToNumber(fromX) != fromY && fromX != (int) EmptySquare) fromX++;
+ fromY = DROP_RANK;
}
--
- /* [HGM] <popupFix> The following if has been moved here from
- UserMoveEvent(). Because it seemed to belong here (why not allow
- piece drops in training games?), and because it can only be
- performed after it is known to what we promote. */
- if (gameMode == Training) {
++
+ /* [HGM] <popupFix> The following if has been moved here from
- UserMoveEvent(). Because it seemed to belon here (why not allow
++ UserMoveEvent(). Because it seemed to belong here (why not allow
+ piece drops in training games?), and because it can only be
+ performed after it is known to what we promote. */
- if (gameMode == Training)
++ if (gameMode == Training)
+ {
/* compare the move played on the board to the next move in the
- * game. If they match, display the move and the opponent's response.
+ * game. If they match, display the move and the opponent's response.
* If they don't match, display an error message.
*/
int saveAnimate;
- Board testBoard; char testRights[BOARD_SIZE]; char testStatus;
+ Board testBoard;
CopyBoard(testBoard, boards[currentMove]);
- ApplyMove(fromX, fromY, toX, toY, promoChar, testBoard, testRights, &testStatus);
+ ApplyMove(fromX, fromY, toX, toY, promoChar, testBoard);
- if (CompareBoards(testBoard, boards[currentMove+1])) {
- ForwardInner(currentMove+1);
+ if (CompareBoards(testBoard, boards[currentMove+1]))
+ {
+ ForwardInner(currentMove+1);
- /* Autoplay the opponent's response.
- * if appData.animate was TRUE when Training mode was entered,
- * the response will be animated.
- */
- saveAnimate = appData.animate;
- appData.animate = animateTraining;
- ForwardInner(currentMove+1);
- appData.animate = saveAnimate;
-
- /* check for the end of the game */
- if (currentMove >= forwardMostMove) {
- gameMode = PlayFromGameFile;
- ModeHighlight();
- SetTrainingModeOff();
- DisplayInformation(_("End of game"));
+ /* Autoplay the opponent's response.
+ * if appData.animate was TRUE when Training mode was entered,
+ * the response will be animated.
+ */
+ saveAnimate = appData.animate;
+ appData.animate = animateTraining;
+ ForwardInner(currentMove+1);
+ appData.animate = saveAnimate;
+
+ /* check for the end of the game */
+ if (currentMove >= forwardMostMove)
+ {
+ gameMode = PlayFromGameFile;
+ ModeHighlight();
+ SetTrainingModeOff();
+ DisplayInformation(_("End of game"));
+ }
+ }
+ else
+ {
+ DisplayError(_("Incorrect move"), 0);
}
- } else {
- DisplayError(_("Incorrect move"), 0);
- }
return 1;
}
MakeMove(fromX, fromY, toX, toY, promoChar); /*updates forwardMostMove*/
- if (gameMode == BeginningOfGame) {
- if (appData.noChessProgram) {
- gameMode = EditGame;
- SetGameInfo();
- } else {
- char buf[MSG_SIZ];
- gameMode = MachinePlaysBlack;
- StartClocks();
- SetGameInfo();
- sprintf(buf, "%s vs. %s", gameInfo.white, gameInfo.black);
- DisplayTitle(buf);
- if (first.sendName) {
- sprintf(buf, "name %s\n", gameInfo.white);
- SendToProgram(buf, &first);
- }
- StartClocks();
+ if (gameMode == BeginningOfGame)
+ {
+ if (appData.noChessProgram)
+ {
+ gameMode = EditGame;
+ SetGameInfo();
+ }
+ else
+ {
+ char buf[MSG_SIZ];
+ gameMode = MachinePlaysBlack;
+ StartClocks();
+ SetGameInfo();
+ sprintf(buf, "%s vs. %s", gameInfo.white, gameInfo.black);
+ DisplayTitle(buf);
+ if (first.sendName)
+ {
+ sprintf(buf, "name %s\n", gameInfo.white);
+ SendToProgram(buf, &first);
+ }
+ StartClocks();
+ }
+ ModeHighlight();
}
- if(appData.debugMode) fprintf(debugFP, "moveType 2 = %d, promochar = %x\n", moveType, promoChar);
+ ModeHighlight();
+ }
/* Relay move to ICS or chess engine */
- if (appData.icsActive) {
- if (gameMode == IcsPlayingWhite || gameMode == IcsPlayingBlack ||
- gameMode == IcsExamining) {
- SendMoveToICS(moveType, fromX, fromY, toX, toY);
- ics_user_moved = 1;
+ if (appData.icsActive)
+ {
+ if (gameMode == IcsPlayingWhite || gameMode == IcsPlayingBlack ||
+ gameMode == IcsExamining)
+ {
+ SendMoveToICS(moveType, fromX, fromY, toX, toY);
+ ics_user_moved = 1;
+ }
}
- } else {
- if (first.sendTime && (gameMode == BeginningOfGame ||
- gameMode == MachinePlaysWhite ||
- gameMode == MachinePlaysBlack)) {
- SendTimeRemaining(&first, gameMode != MachinePlaysBlack);
- }
- if (gameMode != EditGame && gameMode != PlayFromGameFile) {
- // [HGM] book: if program might be playing, let it use book
- bookHit = SendMoveToBookUser(forwardMostMove-1, &first, FALSE);
- first.maybeThinking = TRUE;
- } else SendMoveToProgram(forwardMostMove-1, &first);
- if (currentMove == cmailOldMove + 1) {
- cmailMoveType[lastLoadGameNumber - 1] = CMAIL_MOVE;
+ else
+ {
+ if (first.sendTime && (gameMode == BeginningOfGame ||
+ gameMode == MachinePlaysWhite ||
+ gameMode == MachinePlaysBlack))
+ {
+ SendTimeRemaining(&first, gameMode != MachinePlaysBlack);
+ }
+ if (gameMode != EditGame && gameMode != PlayFromGameFile)
+ {
+ // [HGM] book: if program might be playing, let it use book
+ bookHit = SendMoveToBookUser(forwardMostMove-1, &first, FALSE);
+ first.maybeThinking = TRUE;
+ }
+ else
+ SendMoveToProgram(forwardMostMove-1, &first);
+ if (currentMove == cmailOldMove + 1)
+ {
+ cmailMoveType[lastLoadGameNumber - 1] = CMAIL_MOVE;
+ }
}
ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/
- switch (gameMode)
- switch (gameMode) {
- case EditGame:
- switch (MateTest(boards[currentMove], PosFlags(currentMove)) ) {
- case MT_NONE:
- case MT_CHECK:
- break;
- case MT_CHECKMATE:
- case MT_STAINMATE:
- if (WhiteOnMove(currentMove)) {
- GameEnds(BlackWins, "Black mates", GE_PLAYER);
- } else {
- GameEnds(WhiteWins, "White mates", GE_PLAYER);
- }
++ switch (gameMode)
+ {
+ case EditGame:
- switch (MateTest(boards[currentMove], PosFlags(currentMove),
- EP_UNKNOWN, castlingRights[currentMove]) )
- {
- case MT_NONE:
- case MT_CHECK:
- break;
- case MT_CHECKMATE:
- case MT_STAINMATE:
- if (WhiteOnMove(currentMove))
- {
- GameEnds(BlackWins, "Black mates", GE_PLAYER);
- }
- else
- {
- GameEnds(WhiteWins, "White mates", GE_PLAYER);
- }
- break;
- case MT_STALEMATE:
- GameEnds(GameIsDrawn, "Stalemate", GE_PLAYER);
- break;
- }
- break;
++ switch (MateTest(boards[currentMove], PosFlags(currentMove)) ) {
++ case MT_NONE:
++ case MT_CHECK:
++ break;
+
+ case MachinePlaysBlack:
+ case MachinePlaysWhite:
+ /* disable certain menu options while machine is thinking */
+ SetMachineThinkingEnables();
break;
- case MT_STALEMATE:
- GameEnds(GameIsDrawn, "Stalemate", GE_PLAYER);
+
+ default:
break;
}
- break;
-
- case MachinePlaysBlack:
- case MachinePlaysWhite:
- /* disable certain menu options while machine is thinking */
- SetMachineThinkingEnables();
- break;
-
- default:
- break;
- }
- if(bookHit) { // [HGM] book: simulate book reply
- static char bookMove[MSG_SIZ]; // a bit generous?
+ if(bookHit)
+ { // [HGM] book: simulate book reply
+ static char bookMove[MSG_SIZ]; // a bit generous?
- programStats.nodes = programStats.depth = programStats.time =
+ programStats.nodes = programStats.depth = programStats.time =
programStats.score = programStats.got_only_move = 0;
- sprintf(programStats.movelist, "%s (xbook)", bookHit);
+ sprintf(programStats.movelist, "%s (xbook)", bookHit);
+
+ strcpy(bookMove, "move ");
+ strcat(bookMove, bookHit);
+ HandleMachineMove(bookMove, &first);
+ }
- strcpy(bookMove, "move ");
- strcat(bookMove, bookHit);
- HandleMachineMove(bookMove, &first);
- }
return 1;
}
/* if we hit starting position, add initial plies */
if( count == backwardMostMove )
count -= initialRulePlies;
- count = forwardMostMove - count;
+ count = forwardMostMove - count;
if( count >= 100)
- epStatus[forwardMostMove] = EP_RULE_DRAW;
+ boards[forwardMostMove][EP_STATUS] = EP_RULE_DRAW;
/* this is used to judge if draw claims are legal */
if(appData.ruleMoves > 0 && count >= 2*appData.ruleMoves) {
SendToProgram("force\n", cps->other); // suppress reply
Reset(TRUE, FALSE);
CopyBoard(boards[0], initial_position);
initialRulePlies = FENrulePlies;
- epStatus[0] = FENepStatus;
- for( i=0; i<nrCastlingRights; i++ )
- castlingRights[0][i] = FENcastlingRights[i];
if(blackPlaysFirst) gameMode = MachinePlaysWhite;
- else gameMode = MachinePlaysBlack;
+ else gameMode = MachinePlaysBlack;
DrawPosition(FALSE, boards[currentMove]);
}
return;
if( toY-fromY==2) {
if(toX>BOARD_LEFT && board[toY][toX-1] == BlackPawn &&
gameInfo.variant != VariantBerolina || toX < fromX)
- *ep = toX | berolina;
+ board[EP_STATUS] = toX | berolina;
if(toX<BOARD_RGHT-1 && board[toY][toX+1] == BlackPawn &&
- gameInfo.variant != VariantBerolina || toX > fromX)
- *ep = toX;
- gameInfo.variant != VariantBerolina || toX > fromX)
- board[EP_STATUS] = toX;
++ gameInfo.variant != VariantBerolina || toX > fromX)
++ board[EP_STATUS] = toX;
}
- } else
+ } else
if( board[fromY][fromX] == BlackPawn ) {
if(fromY != toY) // [HGM] Xiangqi sideway Pawn moves should not count as 50-move breakers
- *ep = EP_PAWN_MOVE;
+ board[EP_STATUS] = EP_PAWN_MOVE;
if( toY-fromY== -2) {
if(toX>BOARD_LEFT && board[toY][toX-1] == WhitePawn &&
gameInfo.variant != VariantBerolina || toX < fromX)
done = FALSE;
switch (moveType) {
case Comment:
- if (appData.debugMode)
+ if (appData.debugMode)
fprintf(debugFP, "Parsed Comment: %s\n", yy_text);
p = yy_text;
- if (*p == '{' || *p == '[' || *p == '(') {
- p[strlen(p) - 1] = NULLCHAR;
- p++;
- }
/* append the comment but don't display it */
- while (*p == '\n') p++;
- AppendComment(currentMove, p);
+ AppendComment(currentMove, p, FALSE);
return TRUE;
case WhiteCapturesEnPassant:
promoChar = cmailMove[lastLoadGameNumber - 1][4];
MakeMove(fromX, fromY, toX, toY, promoChar);
ShowMove(fromX, fromY, toX, toY);
-
- switch (MateTest(boards[currentMove], PosFlags(currentMove),
- EP_UNKNOWN, castlingRights[currentMove]) ) {
-
+ switch (MateTest(boards[currentMove], PosFlags(currentMove)) ) {
case MT_NONE:
case MT_CHECK:
break;
/* Handle comments interspersed among the tags */
while (cm == Comment) {
char *p;
- if (appData.debugMode)
+ if (appData.debugMode)
fprintf(debugFP, "Parsed Comment: %s\n", yy_text);
p = yy_text;
- if (*p == '{' || *p == '[' || *p == '(') {
- p[strlen(p) - 1] = NULLCHAR;
- p++;
- }
- while (*p == '\n') p++;
- AppendComment(currentMove, p);
+ AppendComment(currentMove, p, FALSE);
yyboardindex = forwardMostMove;
cm = (ChessMove) yylex();
}
while (cm == Comment) {
char *p;
- if (appData.debugMode)
+ if (appData.debugMode)
fprintf(debugFP, "Parsed Comment: %s\n", yy_text);
p = yy_text;
- if (*p == '{' || *p == '[' || *p == '(') {
- p[strlen(p) - 1] = NULLCHAR;
- p++;
- }
- while (*p == '\n') p++;
- AppendComment(currentMove, p);
+ AppendComment(currentMove, p, FALSE);
yyboardindex = forwardMostMove;
cm = (ChessMove) yylex();
}
{
time_t tm;
char *fen;
-
-
+ if (gameMode == EditPosition) EditPositionDone(TRUE);
if (appData.oldSaveStyle) {
tm = time((time_t *) NULL);
-
+
fprintf(f, "# %s position file -- %s", programName, ctime(&tm));
PrintOpponents(f);
fprintf(f, "[--------------\n");
ToStartEvent()
{
if (gameMode == AnalyzeMode || gameMode == AnalyzeFile) {
- /* to optimze, we temporarily turn off analysis mode while we undo
+ /* to optimize, we temporarily turn off analysis mode while we undo
* all the moves. Otherwise we get analysis output after each undo.
- */
+ */
if (first.analysisSupport) {
SendToProgram("exit\nforce\n", &first);
first.analyzing = FALSE;
int newState = appData.showThinking
// [HGM] thinking: other features now need thinking output as well
|| !appData.hideThinkingFromHuman || appData.adjudicateLossThreshold != 0 || EngineOutputIsUp();
-
+
if (oldState == newState) return;
oldState = newState;
- if (gameMode == EditPosition) EditPositionDone();
+ if (gameMode == EditPosition) EditPositionDone(TRUE);
if (oldState) {
SendToProgram("post\n", &first);
if (gameMode == TwoMachinesPlay) {
/* read e.p. field in games that know e.p. capture */
if(gameInfo.variant != VariantShogi && gameInfo.variant != VariantXiangqi &&
- gameInfo.variant != VariantShatranj && gameInfo.variant != VariantCourier ) {
+ gameInfo.variant != VariantShatranj && gameInfo.variant != VariantCourier ) {
if(*p=='-') {
- p++; FENepStatus = EP_NONE;
+ p++; board[EP_STATUS] = EP_NONE;
} else {
char c = *p++ - AAA;
# define N_(s) s
#endif
-#define _LL_ 100
-
-extern Widget formWidget, shellWidget, boardWidget, menuBarWidget;
-extern Display *xDisplay;
-extern int squareSize;
-extern Pixmap xMarkPixmap;
-extern char *layoutName;
-
-struct History{
- String *Nr,*white,*black;
- int aNr; /* space actually alocated */
- Widget mvn,mvw,mvb,vbox,viewport,sh;
- char Up;
-};
+extern GtkWidget *GUI_History;
+extern GtkListStore *LIST_MoveHistory;
-struct History *hist=0;
String dots=" ... ";
+ Position gameHistoryX, gameHistoryY;
+ Dimension gameHistoryW;
void
-HistoryPopDown(w, client_data, call_data)
- Widget w;
- XtPointer client_data, call_data;
+HistoryPopDown(object, user_data)
+ GtkObject *object;
+ gpointer user_data;
{
- Arg args[16];
- int j;
- if(hist) {
- XtPopdown(hist->sh);
- hist->Up=False;
- }
- j=0;
- XtSetArg(args[j], XtNleftBitmap, None); j++;
- XtSetValues(XtNameToWidget(menuBarWidget, "menuMode.Show Move History"),
- args, j);
+ gtk_widget_hide (GUI_History);
+ return;
}
void HistoryMoveProc(Widget w, XtPointer closure, XtPointer call_data)
<Key>Left: BackwardProc() \n \
<Key>Down: ForwardProc() \n \
<Key>Right: ForwardProc() \n";
- /*--- allocate memory for move-strings ---*/
- HistoryAlloc(_LL_);
+ return;
+ /*-------- create the widgets ---------------*/
- j = 0;
- XtSetArg(args[j], XtNresizable, True); j++;
- XtSetArg(args[j], XtNallowShellResize, True); j++;
-#if TOPLEVEL
- hist->sh =
- XtCreatePopupShell(_("Move list"), topLevelShellWidgetClass,
- shellWidget, args, j);
-#else
- hist->sh =
- XtCreatePopupShell(_("Move list"), transientShellWidgetClass,
- shellWidget, args, j);
-#endif
- j = 0;
- XtSetArg(args[j], XtNborderWidth, 0); j++;
- XtSetArg(args[j], XtNdefaultDistance, 0); j++;
- layout =
- XtCreateManagedWidget(layoutName, formWidgetClass, hist->sh,
- args, j);
-
- j = 0;
- XtSetArg(args[j], XtNborderWidth, 0); j++;
- XtSetArg(args[j], XtNresizable, True); j++;
-
- form =
- XtCreateManagedWidget("form", formWidgetClass, layout, args, j);
- j=0;
-
- j = 0;
-
- XtSetArg(args[j], XtNtop, XtChainTop); j++;
- XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
- XtSetArg(args[j], XtNleft, XtChainLeft); j++;
- XtSetArg(args[j], XtNright, XtChainRight); j++;
-
- XtSetArg(args[j], XtNborderWidth, 1); j++;
- XtSetArg(args[j], XtNresizable, False); j++;
- XtSetArg(args[j], XtNallowVert, True); j++;
- XtSetArg(args[j], XtNallowHoriz, True); j++;
- XtSetArg(args[j], XtNforceBars, False); j++;
- XtSetArg(args[j], XtNheight, 280); j++;
- hist->viewport =
- XtCreateManagedWidget("viewport", viewportWidgetClass,
- form, args, j);
- j=0;
- XtSetArg(args[j], XtNborderWidth, 0); j++;
- XtSetArg(args[j], XtNorientation,XtorientHorizontal);j++;
- hist->vbox =
- XtCreateManagedWidget("vbox", formWidgetClass, hist->viewport, args, j);
-
- j=0;
- XtSetArg(args[j], XtNtop, XtChainTop); j++;
- XtSetArg(args[j], XtNbottom, XtChainTop); j++;
- XtSetArg(args[j], XtNleft, XtChainLeft); j++;
- XtSetArg(args[j], XtNright, XtChainLeft); j++;
-
- XtSetArg(args[j], XtNdefaultColumns, 1); j++;
- XtSetArg(args[j], XtNforceColumns, True); j++;
- XtSetArg(args[j], XtNverticalList, True); j++;
- XtSetArg(args[j], XtNborderWidth, 0); j++;
- XtSetArg(args[j], XtNresizable,True);j++;
- XtSetArg(args[j], XtNleft, XtChainLeft); j++;
- hist->mvn = XtCreateManagedWidget("movesn", listWidgetClass,
- hist->vbox, args, j);
- XtAddCallback(hist->mvn, XtNcallback, HistoryMoveProc, (XtPointer) hist);
-
- j=0;
- XtSetArg(args[j], XtNtop, XtChainTop); j++;
- XtSetArg(args[j], XtNbottom, XtChainTop); j++;
- XtSetArg(args[j], XtNleft, XtChainLeft); j++;
- XtSetArg(args[j], XtNright, XtRubber); j++;
-
- XtSetArg(args[j], XtNdefaultColumns, 1); j++;
- XtSetArg(args[j], XtNforceColumns, True); j++;
- XtSetArg(args[j], XtNverticalList, True); j++;
- XtSetArg(args[j], XtNborderWidth, 0); j++;
- XtSetArg(args[j], XtNresizable,True);j++;
- XtSetArg(args[j], XtNfromHoriz, hist->mvn); j++;
- hist->mvw = XtCreateManagedWidget("movesw", listWidgetClass,
- hist->vbox, args, j);
- XtAddCallback(hist->mvw, XtNcallback, HistoryMoveProc, (XtPointer) hist);
-
- j=0;
- XtSetArg(args[j], XtNtop, XtChainTop); j++;
- XtSetArg(args[j], XtNbottom, XtChainTop); j++;
- XtSetArg(args[j], XtNleft, XtRubber); j++;
- XtSetArg(args[j], XtNright, XtRubber); j++;
-
- XtSetArg(args[j], XtNdefaultColumns, 1); j++;
- XtSetArg(args[j], XtNforceColumns, True); j++;
- XtSetArg(args[j], XtNverticalList, True); j++;
- XtSetArg(args[j], XtNborderWidth, 0); j++;
- XtSetArg(args[j], XtNresizable,True);j++;
- XtSetArg(args[j], XtNfromHoriz, hist->mvw); j++;
- hist->mvb = XtCreateManagedWidget("movesb", listWidgetClass,
- hist->vbox, args, j);
- XtAddCallback(hist->mvb, XtNcallback, HistoryMoveProc, (XtPointer) hist);
-
- j=0;
- XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
- XtSetArg(args[j], XtNtop, XtChainBottom); j++;
- XtSetArg(args[j], XtNleft, XtChainLeft); j++;
- XtSetArg(args[j], XtNright, XtChainLeft); j++;
- XtSetArg(args[j], XtNfromVert, hist->viewport); j++;
- b_close= XtCreateManagedWidget(_("Close"), commandWidgetClass,
- form, args, j);
- XtAddCallback(b_close, XtNcallback, HistoryPopDown, (XtPointer) 0);
-
- XtAugmentTranslations(hist->sh,XtParseTranslationTable (trstr));
-
- XtRealizeWidget(hist->sh);
- CatchDeleteWindow(hist->sh, "HistoryPopDown");
-
- for(i=1;i<hist->aNr;i++){
- strcpy(hist->white[i],dots);
- strcpy(hist->black[i],"");
- }
-
- // [HGM] restore old position
- j = 0;
- XtSetArg(args[j], XtNx, &gameHistoryX); j++;
- XtSetArg(args[j], XtNy, &gameHistoryY); j++;
- XtSetArg(args[j], XtNwidth, &gameHistoryW); j++;
- XtGetValues(shellWidget, args, j);
- j = 0;
- XtSetArg(args[j], XtNx, gameHistoryX + gameHistoryW); j++;
- XtSetArg(args[j], XtNy, gameHistoryY); j++;
- XtSetValues(hist->sh, args, j);
- XtRealizeWidget(hist->sh);
-
- return hist->sh;
++// j = 0;
++// XtSetArg(args[j], XtNresizable, True); j++;
++// XtSetArg(args[j], XtNallowShellResize, True); j++;
++//#if TOPLEVEL
++// hist->sh =
++// XtCreatePopupShell(_("Move list"), topLevelShellWidgetClass,
++// shellWidget, args, j);
++//#else
++// hist->sh =
++// XtCreatePopupShell(_("Move list"), transientShellWidgetClass,
++// shellWidget, args, j);
++//#endif
++// j = 0;
++// XtSetArg(args[j], XtNborderWidth, 0); j++;
++// XtSetArg(args[j], XtNdefaultDistance, 0); j++;
++// layout =
++// XtCreateManagedWidget(layoutName, formWidgetClass, hist->sh,
++// args, j);
++//
++// j = 0;
++// XtSetArg(args[j], XtNborderWidth, 0); j++;
++// XtSetArg(args[j], XtNresizable, True); j++;
++//
++// form =
++// XtCreateManagedWidget("form", formWidgetClass, layout, args, j);
++// j=0;
++//
++// j = 0;
++//
++// XtSetArg(args[j], XtNtop, XtChainTop); j++;
++// XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
++// XtSetArg(args[j], XtNleft, XtChainLeft); j++;
++// XtSetArg(args[j], XtNright, XtChainRight); j++;
++//
++// XtSetArg(args[j], XtNborderWidth, 1); j++;
++// XtSetArg(args[j], XtNresizable, False); j++;
++// XtSetArg(args[j], XtNallowVert, True); j++;
++// XtSetArg(args[j], XtNallowHoriz, True); j++;
++// XtSetArg(args[j], XtNforceBars, False); j++;
++// XtSetArg(args[j], XtNheight, 280); j++;
++// hist->viewport =
++// XtCreateManagedWidget("viewport", viewportWidgetClass,
++// form, args, j);
++// j=0;
++// XtSetArg(args[j], XtNborderWidth, 0); j++;
++// XtSetArg(args[j], XtNorientation,XtorientHorizontal);j++;
++// hist->vbox =
++// XtCreateManagedWidget("vbox", formWidgetClass, hist->viewport, args, j);
++//
++// j=0;
++// XtSetArg(args[j], XtNtop, XtChainTop); j++;
++// XtSetArg(args[j], XtNbottom, XtChainTop); j++;
++// XtSetArg(args[j], XtNleft, XtChainLeft); j++;
++// XtSetArg(args[j], XtNright, XtChainLeft); j++;
++//
++// XtSetArg(args[j], XtNdefaultColumns, 1); j++;
++// XtSetArg(args[j], XtNforceColumns, True); j++;
++// XtSetArg(args[j], XtNverticalList, True); j++;
++// XtSetArg(args[j], XtNborderWidth, 0); j++;
++// XtSetArg(args[j], XtNresizable,True);j++;
++// XtSetArg(args[j], XtNleft, XtChainLeft); j++;
++// hist->mvn = XtCreateManagedWidget("movesn", listWidgetClass,
++// hist->vbox, args, j);
++// XtAddCallback(hist->mvn, XtNcallback, HistoryMoveProc, (XtPointer) hist);
++//
++// j=0;
++// XtSetArg(args[j], XtNtop, XtChainTop); j++;
++// XtSetArg(args[j], XtNbottom, XtChainTop); j++;
++// XtSetArg(args[j], XtNleft, XtChainLeft); j++;
++// XtSetArg(args[j], XtNright, XtRubber); j++;
++//
++// XtSetArg(args[j], XtNdefaultColumns, 1); j++;
++// XtSetArg(args[j], XtNforceColumns, True); j++;
++// XtSetArg(args[j], XtNverticalList, True); j++;
++// XtSetArg(args[j], XtNborderWidth, 0); j++;
++// XtSetArg(args[j], XtNresizable,True);j++;
++// XtSetArg(args[j], XtNfromHoriz, hist->mvn); j++;
++// hist->mvw = XtCreateManagedWidget("movesw", listWidgetClass,
++// hist->vbox, args, j);
++// XtAddCallback(hist->mvw, XtNcallback, HistoryMoveProc, (XtPointer) hist);
++//
++// j=0;
++// XtSetArg(args[j], XtNtop, XtChainTop); j++;
++// XtSetArg(args[j], XtNbottom, XtChainTop); j++;
++// XtSetArg(args[j], XtNleft, XtRubber); j++;
++// XtSetArg(args[j], XtNright, XtRubber); j++;
++//
++// XtSetArg(args[j], XtNdefaultColumns, 1); j++;
++// XtSetArg(args[j], XtNforceColumns, True); j++;
++// XtSetArg(args[j], XtNverticalList, True); j++;
++// XtSetArg(args[j], XtNborderWidth, 0); j++;
++// XtSetArg(args[j], XtNresizable,True);j++;
++// XtSetArg(args[j], XtNfromHoriz, hist->mvw); j++;
++// hist->mvb = XtCreateManagedWidget("movesb", listWidgetClass,
++// hist->vbox, args, j);
++// XtAddCallback(hist->mvb, XtNcallback, HistoryMoveProc, (XtPointer) hist);
++//
++// j=0;
++// XtSetArg(args[j], XtNbottom, XtChainBottom); j++;
++// XtSetArg(args[j], XtNtop, XtChainBottom); j++;
++// XtSetArg(args[j], XtNleft, XtChainLeft); j++;
++// XtSetArg(args[j], XtNright, XtChainLeft); j++;
++// XtSetArg(args[j], XtNfromVert, hist->viewport); j++;
++// b_close= XtCreateManagedWidget(_("Close"), commandWidgetClass,
++// form, args, j);
++// XtAddCallback(b_close, XtNcallback, HistoryPopDown, (XtPointer) 0);
++//
++// XtAugmentTranslations(hist->sh,XtParseTranslationTable (trstr));
++//
++// XtRealizeWidget(hist->sh);
++// CatchDeleteWindow(hist->sh, "HistoryPopDown");
++//
++// for(i=1;i<hist->aNr;i++){
++// strcpy(hist->white[i],dots);
++// strcpy(hist->black[i],"");
++// }
++//
++// // [HGM] restore old position
++// j = 0;
++// XtSetArg(args[j], XtNx, &gameHistoryX); j++;
++// XtSetArg(args[j], XtNy, &gameHistoryY); j++;
++// XtSetArg(args[j], XtNwidth, &gameHistoryW); j++;
++// XtGetValues(shellWidget, args, j);
++// j = 0;
++// XtSetArg(args[j], XtNx, gameHistoryX + gameHistoryW); j++;
++// XtSetArg(args[j], XtNy, gameHistoryY); j++;
++// XtSetValues(hist->sh, args, j);
++// XtRealizeWidget(hist->sh);
++//
++// return hist->sh;
}
void