Package aima.core.environment.map

Examples of aima.core.environment.map.MapEnvironment


     * finding problems, the size of the list needs to be 1.
     */
    @Override
    protected void selectScenarioAndDest(int scenarioIdx, int destIdx) {
      ExtendableMap map = new ExtendableMap();
      MapEnvironment env = new MapEnvironment(map);
      String agentLoc = null;
      switch (scenarioIdx) {
      case 0:
        SimplifiedRoadMapOfPartOfRomania.initMap(map);
        agentLoc = SimplifiedRoadMapOfPartOfRomania.ARAD;
View Full Code Here


    public void initAgents(MessageLogger logger) {
      if (destinations.size() != 1) {
        logger.log("Error: This agent requires exact one destination.");
        return;
      }
      MapEnvironment env = scenario.getEnv();
      String goal = destinations.get(0);
      MapAgent agent = new MapAgent(env.getMap(), env, search, new String[] { goal });
      env.addAgent(agent, scenario.getInitAgentLocation());
    }
View Full Code Here

  public void run(MessageLogger logger) {
    logger.log("<simulation-protocol>");
    logger.log("search: " + search.getClass().getName());
    if (heuristic != null)
      logger.log("heuristic: " + heuristic.getClass().getName());
    MapEnvironment env = scenario.getEnv();
    if (env.getAgents().isEmpty())
      initAgents(logger);
    try {
      while (!env.isDone() && !frame.simulationPaused()) {
        Thread.sleep(sleepTime);
        env.step();
      }
    } catch (InterruptedException e) {}
    logger.log("</simulation-protocol>\n");
  }
View Full Code Here

   * Calls {@link #initAgents(MessageLogger)} if necessary and
   * then executes one simulation step.
   */
  @Override
  public void step(MessageLogger logger) {
    MapEnvironment env = scenario.getEnv();
    if (env.getAgents().isEmpty())
      initAgents(logger);
    env.step();
  }
View Full Code Here

   * Reacts on environment changes and updates the agent tracks. The command
   * is always send to the message logger as string.
   */
  @Override
  public void agentActed(Agent agent, Action command, EnvironmentState state) {
    MapEnvironment mEnv = getMapEnv();
    String msg = "";
    if (mEnv.getAgents().size() > 1)
      msg = "A" + mEnv.getAgents().indexOf(agent) + ": ";
    notify(msg + command.toString());
    updateTracks();
    repaint();
  }
View Full Code Here

    }
  }

  /** Updates all tracks with respect to the current agent locations. */
  protected void updateTracks() {
    MapEnvironment mEnv = getMapEnv();
    if (mEnv != null)
      for (Agent a : mEnv.getAgents()) {
        List<String> aTrack = getTrack(a);
        String aLoc = mEnv.getAgentLocation(a);
        if (aTrack == null) {
          aTrack = new ArrayList<String>();
          agentTracks.put(a, aTrack);
        }
        if (aTrack.isEmpty() || !aTrack.get(aTrack.size()-1).equals(aLoc))
View Full Code Here

  }
 
  /** Returns the locations of all agents. */
  protected List<String> getAgentLocs() {
    List<String> result = new ArrayList<String>();
    MapEnvironment mEnv = getMapEnv();
    for (Agent a : mEnv.getAgents())
      result.add(mEnv.getAgentLocation(a));
    return result;
  }
View Full Code Here

    prepare(null);
  }

  @Override
  public void prepare(String changedSelector) {
    env = new MapEnvironment(map);
    MapAgentFrame.SelectionState state = frame.getSelection();
   
    map.getOsmMap().getTracks().clear();
    switch (state.getValue(MapAgentFrame.SCENARIO_SEL)) {
    case 0: map.setMapWayFilter
View Full Code Here

    aMap.addBidirectionalLink("E", "F", 5.0);
    aMap.addBidirectionalLink("F", "G", 5.0);
    aMap.addBidirectionalLink("G", "H", 5.0);
    aMap.addUnidirectionalLink("B", "H", 5.0);

    MapEnvironment me = new MapEnvironment(aMap);
    MapAgent ma = new MapAgent(me.getMap(), me, bidirectionalSearch,
        new String[] { "H" });
    me.addAgent(ma, "A");
    me.addEnvironmentView(new BDSEnvironmentView());
    me.stepUntilDone();

    Assert.assertEquals(
        "CurrentLocation=In(A), Goal=In(H):Action[name==moveTo, location==B]:Action[name==moveTo, location==H]:METRIC[pathCost]=10.0:METRIC[maxQueueSize]=3:METRIC[queueSize]=3:METRIC[nodesExpanded]=8:Action[name==NoOp]:",
        envChanges.toString());
View Full Code Here

    aMap.addBidirectionalLink("C", "D", 5.0);
    aMap.addBidirectionalLink("D", "E", 5.0);
    aMap.addBidirectionalLink("E", "F", 5.0);
    aMap.addUnidirectionalLink("E", "A", 5.0);

    MapEnvironment me = new MapEnvironment(aMap);
    MapAgent ma = new MapAgent(me.getMap(), me, bidirectionalSearch,
        new String[] { "F" });
    me.addAgent(ma, "A");
    me.addEnvironmentView(new BDSEnvironmentView());
    me.stepUntilDone();

    Assert.assertEquals(
        "CurrentLocation=In(A), Goal=In(F):Action[name==moveTo, location==B]:Action[name==moveTo, location==C]:Action[name==moveTo, location==D]:Action[name==moveTo, location==E]:Action[name==moveTo, location==F]:METRIC[pathCost]=25.0:METRIC[maxQueueSize]=3:METRIC[queueSize]=3:METRIC[nodesExpanded]=8:Action[name==NoOp]:",
        envChanges.toString());
View Full Code Here

TOP

Related Classes of aima.core.environment.map.MapEnvironment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.