From 3199eee26cc527b2f6b976e7e136207ed381962c Mon Sep 17 00:00:00 2001 From: Robert Sprunk Date: Mon, 27 Jan 2014 12:55:06 +0100 Subject: [PATCH] MCLThreadVerwalter vergessen --- .../statemachine/hu/MCLThreadVerwalter.java | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/org/ggp/base/player/gamer/statemachine/hu/MCLThreadVerwalter.java diff --git a/src/org/ggp/base/player/gamer/statemachine/hu/MCLThreadVerwalter.java b/src/org/ggp/base/player/gamer/statemachine/hu/MCLThreadVerwalter.java new file mode 100644 index 000000000..ef2b8f6e8 --- /dev/null +++ b/src/org/ggp/base/player/gamer/statemachine/hu/MCLThreadVerwalter.java @@ -0,0 +1,74 @@ +package org.ggp.base.player.gamer.statemachine.hu; + +import java.util.ArrayList; +import java.util.List; + +import org.ggp.base.util.statemachine.MachineState; +import org.ggp.base.util.statemachine.Move; +import org.ggp.base.util.statemachine.StateMachine; +import org.ggp.base.util.statemachine.exceptions.MoveDefinitionException; +import org.ggp.base.util.statemachine.exceptions.TransitionDefinitionException; + +public class MCLThreadVerwalter extends Thread { + + Tromboter player; + MachineState state; + StateMachine mymachine; + ArrayList threads; + Double[] scores; + boolean run = true; + + MCLThreadVerwalter(Double[] scores, StateMachine mymachine, Tromboter player){ + super(); + + this.mymachine = mymachine; + this.player = player; + this.scores = scores; + + state = player.getCurrentState(); + } + + @Override public void run(){ + + try { + + int i = 0; + for (List ownMove:mymachine.getLegalJointMoves(player.getCurrentState())){ + // do thread magic here + MCL_thread t = new MCL_thread( scores[i], mymachine,mymachine.getNextState(state, ownMove), player); + t.start(); + threads.add(t); + i++; + } + + } catch (MoveDefinitionException | TransitionDefinitionException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + // thread verwaltung + /*boolean allDone = false; + while (!allDone) { + allDone = true; + for (double score:scores) { + if (score == -1) { + allDone = false; + } + } + }*/ + while(run); + + + } + + + void stopMinions(){ + for(int i=0; i < threads.size(); i++){ + threads.get(i).stopThread(); + } + } + + void stopThread(){ + run = false; + } +}