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 abf96caf1..e075dd2cf 100644 --- a/src/org/ggp/base/player/gamer/statemachine/hu/Tromboter.java +++ b/src/org/ggp/base/player/gamer/statemachine/hu/Tromboter.java @@ -10,7 +10,6 @@ import org.ggp.base.player.gamer.exception.GamePreviewException; import org.ggp.base.player.gamer.statemachine.StateMachineGamer; import org.ggp.base.util.game.Game; -import org.ggp.base.util.gdl.grammar.GdlPool; import org.ggp.base.util.logging.GamerLogger; import org.ggp.base.util.statemachine.MachineState; import org.ggp.base.util.statemachine.Move; @@ -41,6 +40,8 @@ public final class Tromboter extends StateMachineGamer * */ int i = 0; + + boolean justOneTime = true; @Override public Move stateMachineSelectMove(long timeout) throws TransitionDefinitionException, MoveDefinitionException, GoalDefinitionException { @@ -67,49 +68,99 @@ public Move stateMachineSelectMove(long timeout) throws TransitionDefinitionExce output.append("\n\n"); //GamerLogger.emitToConsole(output.toString()); + while (true) { if (System.currentTimeMillis() > timeout - 500) { - break; + break; } try { List nodeScores = new ArrayList(); nodeScores.clear(); - for (List amove:getStateMachine().getLegalJointMoves(getCurrentState())) { - try { - nodeScores.add(new Integer(getNodeScore(getStateMachine().getNextState(getCurrentState(), amove)))); - } catch (TransitionDefinitionException e) { - e.printStackTrace(); - return selection; + List scoredMoves = new ArrayList(); + int k = 0; + + for (Move ownMove:moves){ + for (List amove:getStateMachine().getLegalJointMoves(getCurrentState(),getRole(),ownMove)) { + try { + nodeScores.add(new Integer(getNodeScore(getStateMachine().getNextState(getCurrentState(), amove)))); + } catch (TransitionDefinitionException e) { + e.printStackTrace(); + return selection; + } } + + if(getStateMachine().getLegalMoves(getCurrentState(), getRole()).size() == 1){ + scoredMoves.add(100); + for(Integer score:nodeScores){ + if(score < scoredMoves.get(k)){ + scoredMoves.set(k, score); + } + } + }else{ + scoredMoves.add(0); + for(Integer score:nodeScores){ + if(score > scoredMoves.get(k)){ + scoredMoves.set(k, score); + } + } + } + k++; + } - // Gegner ist am Zug - if(getStateMachine().getLegalMoves(getCurrentState(), getRole()).size() == 1) { - int myscore = Collections.min(nodeScores); - Move mymove = mymachine.getLegalMoves(getCurrentState(), getRole()).get(nodeScores.indexOf(myscore)); + + // debug output first strike + if(justOneTime){ + justOneTime = false; + StringBuilder debug_output = new StringBuilder(); - debug_output.append("myscore: "); - debug_output.append(myscore); - debug_output.append("; "); - debug_output.append("mymove: "); - debug_output.append(mymove); + debug_output.append("scoredMoves: "); + debug_output.append(scoredMoves); debug_output.append("\n"); GamerLogger.emitToConsole(debug_output.toString()); + } + + // Gegner ist am Zug + if(getStateMachine().getLegalMoves(getCurrentState(), getRole()).size() == 1) { + int myscore = Collections.min(scoredMoves); + Move mymove = selection; + try{ + mymove = mymachine.getLegalMoves(getCurrentState(), getRole()).get(scoredMoves.indexOf(myscore)); + } catch (Exception e) { + StringBuilder debug_output = new StringBuilder(); + debug_output.append("myscore: "); + debug_output.append(myscore); + debug_output.append("; "); + debug_output.append("mymove: "); + debug_output.append(mymove); + debug_output.append("\n"); + debug_output.append("nodeScores"); + debug_output.append(nodeScores); + debug_output.append("\n"); + debug_output.append("Index"); + debug_output.append(nodeScores.indexOf(myscore)); + debug_output.append("\n"); + debug_output.append("legalJointMoves"); + debug_output.append(getStateMachine().getLegalJointMoves(getCurrentState())); + debug_output.append("\n"); + GamerLogger.emitToConsole(debug_output.toString()); + + } return mymove; } else { - int myscore = Collections.min(nodeScores); - GamerLogger.emitToConsole(getStateMachine().getLegalMoves(getCurrentState(), getRole()).get(0).toString()); + int myscore = Collections.min(scoredMoves); + /*GamerLogger.emitToConsole(getStateMachine().getLegalMoves(getCurrentState(), getRole()).get(0).toString()); GamerLogger.emitToConsole("\n"); GamerLogger.emitToConsole(new Move(GdlPool.getConstant("NOOP")).toString()); - GamerLogger.emitToConsole("\n"); - Move mymove = mymachine.getLegalMoves(getCurrentState(), getRole()).get(nodeScores.indexOf(myscore)); - StringBuilder debug_output = new StringBuilder(); + GamerLogger.emitToConsole("\n");*/ + Move mymove = mymachine.getLegalMoves(getCurrentState(), getRole()).get(scoredMoves.indexOf(myscore)); + /*StringBuilder debug_output = new StringBuilder(); debug_output.append("myscore: "); debug_output.append(myscore); debug_output.append("; "); debug_output.append("mymove: "); debug_output.append(mymove); debug_output.append("\n"); - GamerLogger.emitToConsole(debug_output.toString()); + GamerLogger.emitToConsole(debug_output.toString());*/ return mymove; } } catch (MoveDefinitionException e) {