mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2024-11-27 14:15:16 +01:00
DroidFish: Fixed time management bug triggered by ponder mode.
This commit is contained in:
parent
96cfc46536
commit
0faf8a49ca
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user