Пример #1
0
  /**
   * Main method for exploring the domain. The initial state will have 3 red blocks starting on the
   * table. By default this method will launch the visual explorer. Pass a "t" argument to use the
   * terminal explorer.
   *
   * @param args process arguments
   */
  public static void main(String[] args) {

    BlocksWorld bw = new BlocksWorld();
    Domain domain = bw.generateDomain();

    State s = getNewState(domain, 3);

    int expMode = 1;
    if (args.length > 0) {
      if (args[0].equals("v")) {
        expMode = 1;
      } else if (args[0].equals("t")) {
        expMode = 0;
      }
    }

    if (expMode == 0) {

      TerminalExplorer exp = new TerminalExplorer(domain, s);

      exp.explore();

    } else if (expMode == 1) {
      VisualExplorer exp = new VisualExplorer(domain, BlocksWorldVisualizer.getVisualizer(24), s);

      exp.initGUI();
    }
  }
  public void launchExplorer() {

    VisualExplorer exp = new VisualExplorer(domain, v, initialState);

    exp.addKeyAction("w", GridWorldDomain.ACTIONNORTH);
    exp.addKeyAction("s", GridWorldDomain.ACTIONSOUTH);
    exp.addKeyAction("d", GridWorldDomain.ACTIONEAST);
    exp.addKeyAction("a", GridWorldDomain.ACTIONWEST);

    StateParser sp = new GridWorldStateParser(this.domain);

    exp.enableEpisodeRecording("r", "f", new NullRewardFunction(), expertDir, sp);

    // final PuddleMapFVComponent fvg = new PuddleMapFVComponent(this.puddleMap, 5, 20, 20);
    final PuddleMapFV fvg = new PuddleMapFV(this.puddleMap, 5, 20, 20);
    ActionObserver obs =
        new ActionObserver() {
          @Override
          public void actionEvent(State s, GroundedAction ga, State sp) {
            double[] vec = fvg.generateFeatureVectorFrom(sp);
            System.out.println(Arrays.toString(vec));
          }
        };
    ((SADomain) this.domain).addActionObserverForAllAction(obs);

    exp.initGUI();
  }
  public static void main(String[] args) {

    ExampleGridWorld gen = new ExampleGridWorld();
    Domain domain = gen.generateDomain();

    State initialState = ExampleGridWorld.getExampleState(domain);

    // TerminalExplorer exp = new TerminalExplorer(domain);
    // exp.exploreFromState(initialState);

    Visualizer v = gen.getVisualizer();
    VisualExplorer exp = new VisualExplorer(domain, v, initialState);

    exp.addKeyAction("w", ACTIONNORTH);
    exp.addKeyAction("s", ACTIONSOUTH);
    exp.addKeyAction("d", ACTIONEAST);
    exp.addKeyAction("a", ACTIONWEST);

    exp.initGUI();
  }