From 79781e91044a2b400e263537253245729ab65877 Mon Sep 17 00:00:00 2001 From: Robert Sprunk Date: Mon, 16 Dec 2013 12:13:04 +0100 Subject: [PATCH] timeout fix --- .../player/gamer/statemachine/hu/Tromboter.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/org/ggp/base/player/gamer/statemachine/hu/Tromboter.java b/src/org/ggp/base/player/gamer/statemachine/hu/Tromboter.java index 05b8f77e5..13fa75c49 100644 --- a/src/org/ggp/base/player/gamer/statemachine/hu/Tromboter.java +++ b/src/org/ggp/base/player/gamer/statemachine/hu/Tromboter.java @@ -41,11 +41,15 @@ public final class Tromboter extends StateMachineGamer int i = 0; boolean justOneTime = true; + long finish_by = 0; @Override public Move stateMachineSelectMove(long timeout) throws TransitionDefinitionException, MoveDefinitionException, GoalDefinitionException { // We get the current start time long start = System.currentTimeMillis(); + + finish_by = timeout - 500; + StateMachine mymachine = getStateMachine(); /** @@ -67,13 +71,6 @@ public Move stateMachineSelectMove(long timeout) throws TransitionDefinitionExce output.append("\n\n"); //GamerLogger.emitToConsole(output.toString()); - /* - while (true) { - if (System.currentTimeMillis() > timeout - 500) { - break; - } - }*/ - try { List nodeScores = new ArrayList(); for (List ownMove:mymachine.getLegalJointMoves(getCurrentState())){ @@ -158,7 +155,7 @@ private int getNodeScore(MachineState state) throws MoveDefinitionException, Goa List moves = mymachine.getLegalMoves(state, getRole()); int myscore = 0; Move selection = moves.get(0); - if (mymachine.isTerminal(state)) { + if (System.currentTimeMillis() > finish_by || mymachine.isTerminal(state)) { return mymachine.getGoal(state, getRole()); } List nodeScores = new ArrayList();