DroidFish: Fixed time management bug triggered by ponder mode.

This commit is contained in:
Peter Osterlund 2013-09-17 17:47:30 +00:00
parent 96cfc46536
commit 0faf8a49ca
2 changed files with 21 additions and 1 deletions

View File

@ -887,12 +887,16 @@ public class DroidChessController {
final Pair<Position, ArrayList<Move>> ph = game.getUCIHistory();
Position currPos = new Position(game.currPos());
long now = System.currentTimeMillis();
if (ponder)
game.timeController.advanceMove(1);
int wTime = game.timeController.getRemainingTime(true, now);
int bTime = game.timeController.getRemainingTime(false, now);
int wInc = game.timeController.getIncrement(true);
int bInc = game.timeController.getIncrement(false);
boolean wtm = currPos.whiteMove;
int movesToGo = game.timeController.getMovesToTC(wtm);
int movesToGo = game.timeController.getMovesToTC(wtm ^ ponder);
if (ponder)
game.timeController.advanceMove(-1);
final Move fPonderMove = ponder ? ponderMove : null;
SearchRequest sr = DroidComputerPlayer.SearchRequest.searchRequest(
searchId, now, ph.first, ph.second, currPos,

View File

@ -66,6 +66,22 @@ public class TimeControl {
elapsed = 0;
}
/** Move current move "delta" half-moves forward. */
public final void advanceMove(int delta) {
while (delta > 0) {
if (!whiteToMove)
currentMove++;
whiteToMove = !whiteToMove;
delta--;
}
while (delta < 0) {
whiteToMove = !whiteToMove;
if (!whiteToMove)
currentMove--;
delta++;
}
}
public final boolean clockRunning() {
return timerT0 != 0;
}