示例#1
0
 public VisualizedWorld(
     SGDomain domain,
     JointActionModel jam,
     JointReward jr,
     TerminalFunction tf,
     SGStateGenerator sg) {
   super(domain, jam, jr, tf, sg);
   this.game = (GridGameRevisited) sg;
   this.vis = GGVisualizer.getVisualizer(game.getWidth(), game.getHeight());
   // TODO Auto-generated constructor stub
 }
示例#2
0
  /** Runs a game until a terminal state is hit. */
  public void runAndVisualizeGame() {

    for (Agent a : agents) {
      a.gameStarting();
    }
    for (String key : agentCumulativeReward.keySet()) {
      agentCumulativeReward.put(key, 0.0);
    }

    // currentState = game.generateState(agents);
    currentState = initialStateGenerator.generateState(agents);

    int visWidth = 1200 * game.getWidth() / (game.getWidth() + game.getHeight());
    int visHeight = 1200 * game.getHeight() / (game.getWidth() + game.getHeight());
    exp = new SGVisualExplorer(domain, vis, currentState, worldModel, visWidth, visHeight);

    exp.initGUI();

    while (!tf.isTerminal(currentState)) {

      try {
        Thread.sleep(1000);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      this.runStage();
      vis.updateState(currentState);
    }

    for (Agent a : agents) {
      a.gameTerminated();
      System.out.println(a.getAgentName() + ": " + agentCumulativeReward.get(a.getAgentName()));
    }

    DPrint.cl(debugId, currentState.getCompleteStateDescription());
  }