コード例 #1
0
ファイル: ExitThread.java プロジェクト: dgrandes/sim2d
  @Override
  public List<Agent> call() throws Exception {
    removedAgents.clear();
    for (Agent a : agentManager.getBackedUpAgents()) {
      for (Exit e : myExits) {
        String agent_exit_id = a.getExitIdentifier();
        if (!agent_exit_id.equals(e.getId())) continue;
        if (e.distanceTo(a) <= 0 || e.contains(a)) {
          if (a.getMovement() instanceof QLearningBaseMovement)
            ((QLearningBaseMovement) a.getMovement()).increaseVictoryCount();
          removedAgents.add(a);
          try {
            // StateLog.get().agentDied(a, Simulator.getSimulation().getCurrentStep() *
            // simEnvironment.getEnvironment().deltaTime);
            Simulator.registerDeletedAgent(
                a,
                Simulator.getSimulation().getCurrentStep()
                    * simEnvironment.getEnvironment().deltaTime);

          } catch (Exception e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
            System.err.println("Crasheo exits en getEnivornment");
          }
        }
      }
    }
    return removedAgents;
  }
コード例 #2
0
ファイル: ExitThread.java プロジェクト: dgrandes/sim2d
 public ExitThread() {
   simEnvironment = Simulator.getSimEnvironment();
   try {
     agentManager = simEnvironment.getAgentManager();
   } catch (Exception e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
     System.out.println("Exits crasheo en getAgentManager");
   }
 }
コード例 #3
0
  public QInterpreterMovement() throws Exception {
    super();
    if (qMatrix.isEmpty()) {
      String filename = "";
      if (QMatrixFilename.equals("")) {
        Simulator.getGuiFrame().showConfirmation("Select QMatrix File To Use:", "QMatrix File");
        filename = Simulator.getGuiFrame().promptUserForFileName();
      } else filename = QMatrixFilename;

      if (filename == null) throw new Exception("Aborting QInterpreter QMatrix Load");
      File fFile = new File(filename);
      Scanner s = new Scanner(new FileReader(fFile));
      try {
        while (s.hasNextLine()) parseQMatrixElement(s.nextLine());
      } finally {
        s.close();
      }
      QMatrixFilename = filename;
      explorationRate = 0;
    }
  }