static ChessProgramState *stalledEngine;
static char stashedInputMove[MSG_SIZ], abortEngineThink, startPieceToChar[MSG_SIZ];
static Boolean prelude;
-static char preludeText[MSG_SIZ];
+static char preludeText[MSG_SIZ], diceRoll[MSG_SIZ];
void
HandleMachineMove (char *message, ChessProgramState *cps)
}
return;
}
+ if(!strncmp(message, "dice ", 5)) { // [HGM] dice: provide dice rolls
+ if(gameMode != TwoMachinesPlay || (cps->twoMachinesColor[0] == 'w') == WhiteOnMove(forwardMostMove)) {
+ static char previousRoll[MSG_SIZ];
+ char buf[MSG_SIZ], *p = message + 5;
+ int n, k, l;
+ sprintf(buf, "pips");
+ while(sscanf(p, "%d", &n) == 1) {
+ k = (random() + 256*random() & 0xFFFF)*n >> 16;
+ l = strlen(buf);
+ snprintf(buf + l, MSG_SIZ - 1 - l, " %d/%d", k+1, n);
+ while(*++p > ' ') {}
+ }
+ l = strlen(diceRoll);
+ if(l == 0) safeStrCpy(previousRoll, diceRoll+1, MSG_SIZ); // remember series from previous turn
+ snprintf(diceRoll + l, MSG_SIZ - l, "%s", buf + 4); // accumulate rolls for display
+ strcat(buf, "\n"); SendToProgram(buf, cps);
+ if(gameMode != TwoMachinesPlay) {
+ int human = (gameMode == MachinePlaysWhite) != WhiteOnMove(forwardMostMove);
+ if(human) snprintf(buf, MSG_SIZ, "Your dice roll:%s (mine %s)", diceRoll, previousRoll);
+ else snprintf(buf, MSG_SIZ, "My dice roll:%s", diceRoll);
+ DisplayTitle(buf);
+ } else if(cps->other->dice) SendToProgram(buf, cps->other);
+ }
+ return;
+ }
/* [HGM] Allow engine to set up a position. Don't ask me why one would
* want this, I was asked to put it in, and obliged.
*/
ChessSquare p = boards[forwardMostMove][toY][toX];
// forwardMostMove++; // [HGM] bare: moved downstream
+ diceRoll[0] = NULLCHAR; // [HGM] dice: consumed by this move
if(kill2X >= 0) x = kill2X, y = kill2Y; else
if(killX >= 0 && killY >= 0) x = killX, y = killY; // [HGM] lion: make SAN move to intermediate square, if there is one
(void) CoordsToAlgebraic(boards[forwardMostMove],
second.maybeThinking = FALSE;
first.bookSuspend = FALSE; // [HGM] book
second.bookSuspend = FALSE;
+ diceRoll[0] = NULLCHAR;
thinkOutput[0] = NULLCHAR;
lastHint[0] = NULLCHAR; hintSrc = 0;
ClearGameInfo(&gameInfo);
if (BoolFeature(&p, "exclude", &cps->excludeMoves, cps)) continue;
if (BoolFeature(&p, "ics", &cps->sendICS, cps)) continue;
if (BoolFeature(&p, "name", &cps->sendName, cps)) continue;
+ if (BoolFeature(&p, "dice", &cps->dice, cps)) continue; // [HGM] dice
if (BoolFeature(&p, "pause", &cps->pause, cps)) continue; // [HGM] pause
if (IntFeature(&p, "done", &val, cps)) {
FeatureDone(cps, val);