Skip to content

Commit

Permalink
timeout fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rspnk committed Dec 16, 2013
1 parent 456963c commit 79781e9
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/org/ggp/base/player/gamer/statemachine/hu/Tromboter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();

/**
Expand All @@ -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<Integer> nodeScores = new ArrayList<Integer>();
for (List<Move> ownMove:mymachine.getLegalJointMoves(getCurrentState())){
Expand Down Expand Up @@ -158,7 +155,7 @@ private int getNodeScore(MachineState state) throws MoveDefinitionException, Goa
List<Move> 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<Integer> nodeScores = new ArrayList<Integer>();
Expand Down

0 comments on commit 79781e9

Please sign in to comment.