mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-12 17:12:40 +01:00
DroidFish: Fixed time management bug triggered by ponder mode.
This commit is contained in:
@@ -887,12 +887,16 @@ public class DroidChessController {
|
|||||||
final Pair<Position, ArrayList<Move>> ph = game.getUCIHistory();
|
final Pair<Position, ArrayList<Move>> ph = game.getUCIHistory();
|
||||||
Position currPos = new Position(game.currPos());
|
Position currPos = new Position(game.currPos());
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
|
if (ponder)
|
||||||
|
game.timeController.advanceMove(1);
|
||||||
int wTime = game.timeController.getRemainingTime(true, now);
|
int wTime = game.timeController.getRemainingTime(true, now);
|
||||||
int bTime = game.timeController.getRemainingTime(false, now);
|
int bTime = game.timeController.getRemainingTime(false, now);
|
||||||
int wInc = game.timeController.getIncrement(true);
|
int wInc = game.timeController.getIncrement(true);
|
||||||
int bInc = game.timeController.getIncrement(false);
|
int bInc = game.timeController.getIncrement(false);
|
||||||
boolean wtm = currPos.whiteMove;
|
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;
|
final Move fPonderMove = ponder ? ponderMove : null;
|
||||||
SearchRequest sr = DroidComputerPlayer.SearchRequest.searchRequest(
|
SearchRequest sr = DroidComputerPlayer.SearchRequest.searchRequest(
|
||||||
searchId, now, ph.first, ph.second, currPos,
|
searchId, now, ph.first, ph.second, currPos,
|
||||||
|
|||||||
@@ -66,6 +66,22 @@ public class TimeControl {
|
|||||||
elapsed = 0;
|
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() {
|
public final boolean clockRunning() {
|
||||||
return timerT0 != 0;
|
return timerT0 != 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user