Package aima.core.environment.map

Examples of aima.core.environment.map.Map


 
  /**
   * Represents roads by lines and locations by name-labeled points.
   */
  protected void paintMap(java.awt.Graphics2D g2) {
    Map envMap = getMapEnv().getMap();
    Map aMap = (agentMap != null) ? agentMap : envMap;
    List<Roadblock> roadblocks = new ArrayList<Roadblock>();
    for (String l1 : envMap.getLocations()) {
      Point2D pt1 = envMap.getPosition(l1);
      List<String> linkedLocs = envMap.getLocationsLinkedTo(l1);
      for (String l2 : aMap.getLocationsLinkedTo(l1))
        if (!linkedLocs.contains(l2))
          linkedLocs.add(l2);
      for (String l2 : linkedLocs) {
        Point2D pt2 = envMap.getPosition(l2);
        g2.setColor(Color.lightGray);
        g2.drawLine(x(pt1), y(pt1), x(pt2), y(pt2));
        boolean blockedInEnv = !envMap.getLocationsLinkedTo(l2)
            .contains(l1);
        boolean blockedInAgent = !aMap.getLocationsLinkedTo(l2)
            .contains(l1);
        roadblocks.add(new Roadblock(pt1, pt2, blockedInEnv,
            blockedInAgent));
        if (blockedInEnv && blockedInAgent) {
          boolean blockedInEnvOtherDir = !envMap
              .getLocationsLinkedTo(l1).contains(l2);
          boolean blockedInAgentOtherDir = !aMap
              .getLocationsLinkedTo(l1).contains(l2);
          roadblocks.add(new Roadblock(pt2, pt1,
              blockedInEnvOtherDir, blockedInAgentOtherDir));
        }
      }
View Full Code Here


      paintRoadblock(g2, block);
  }
 
  /** Displays a map location. */
  protected void paintLoc(Graphics2D g2, String loc) {
    Map map = getMapEnv().getMap();
    Point2D pt = map.getPosition(loc);
    if (pt != null) {
      int x = x(pt);
      int y = y(pt);
      String info = "";
      List<String> track = new ArrayList<String>();
View Full Code Here

   */
  @Override
  public void paint(java.awt.Graphics g) {
    super.paint(g);
    if (env != null) {
      Map map = getMapEnv().getMap();
      if (!map.getLocations().isEmpty()) {
        updateTracks(); // safety first!
        java.awt.Graphics2D g2 = (java.awt.Graphics2D) g;
        adjustTransformation();
        paintMap(g2);
        for (Agent a : env.getAgents())
          paintTrack(g2, a);
        for (String loc : map.getLocations())
          paintLoc(g2, loc);
      }
    }
  }
View Full Code Here

  /**
   * Adjusts offsets and scale so that the whole map fits on the view
   * without scrolling.
   */
  private void adjustTransformation() {
    Map map = getMapEnv().getMap();
    List<String> locs = map.getLocations();
    // adjust coordinates relative to the left upper corner of the graph
    // area
    double minX = Double.POSITIVE_INFINITY;
    double minY = Double.POSITIVE_INFINITY;
    double maxX = Double.NEGATIVE_INFINITY;
    double maxY = Double.NEGATIVE_INFINITY;
    for (String loc : locs) {
      Point2D xy = map.getPosition(loc);
      if (xy.getX() < minX)
        minX = xy.getX();
      if (xy.getY() < minY)
        minY = xy.getY();
      if (xy.getX() > maxX)
View Full Code Here

  /**
   * Represents roads by lines and locations by name-labeled points.
   */
  protected void paintMap(java.awt.Graphics2D g2) {
    Map envMap = getMapEnv().getMap();
    for (String l1 : envMap.getLocations()) {
      Point2D pt1 = envMap.getPosition(l1);
      List<String> linkedLocs = envMap.getLocationsLinkedTo(l1);
      for (String l2 : linkedLocs) {
        Point2D pt2 = envMap.getPosition(l2);
        g2.setColor(Color.lightGray);
        g2.drawLine(x(pt1), y(pt1), x(pt2), y(pt2));
      }
    }
  }
View Full Code Here

    }
  }

  /** The track of the agent is visualized with red lines. */
  private void paintTrack(java.awt.Graphics2D g2, Agent a) {
    Map map = getMapEnv().getMap();
    Point2D lastPt = null;
    g2.setColor(Color.red);
    for (String loc : getTrack(a)) {
      Point2D pt = map.getPosition(loc);
      if (pt != null && lastPt != null) {
        g2.drawLine(x(pt), y(pt), x(lastPt), y(lastPt));
      }
      lastPt = pt;
    }
View Full Code Here

      lastPt = pt;
    }
  }

  protected void paintLoc(java.awt.Graphics2D g2, String loc) {
    Map map = getMapEnv().getMap();
    Point2D pt = map.getPosition(loc);
    if (pt != null) {
      int x = x(pt);
      int y = y(pt);
      String info = "";
      List<String> track = new ArrayList<String>();
View Full Code Here

        agent.getInstrumentation().getProperty("pathCost"));
  }

  @Test
  public void testAIMA3eFigure3_15() throws Exception {
    Map romaniaMap = new SimplifiedRoadMapOfPartOfRomania();
    Problem problem = new Problem(SimplifiedRoadMapOfPartOfRomania.SIBIU,
        MapFunctionFactory.getActionsFunction(romaniaMap),
        MapFunctionFactory.getResultFunction(), new DefaultGoalTest(
            SimplifiedRoadMapOfPartOfRomania.BUCHAREST),
        new MapStepCostFunction(romaniaMap));
View Full Code Here

public class SolutionCheckerTest {

  @Test
  public void testMultiGoalProblem() throws Exception {
    Map romaniaMap = new SimplifiedRoadMapOfPartOfRomania();
    Problem problem = new Problem(SimplifiedRoadMapOfPartOfRomania.ARAD,
        MapFunctionFactory.getActionsFunction(romaniaMap),
        MapFunctionFactory.getResultFunction(), new DualMapGoalTest(
            SimplifiedRoadMapOfPartOfRomania.BUCHAREST,
            SimplifiedRoadMapOfPartOfRomania.HIRSOVA),
View Full Code Here

    }
  }

  @Test
  public void testAIMA3eFigure3_15() throws Exception {
    Map romaniaMap = new SimplifiedRoadMapOfPartOfRomania();
    Problem problem = new Problem(SimplifiedRoadMapOfPartOfRomania.SIBIU,
        MapFunctionFactory.getActionsFunction(romaniaMap),
        MapFunctionFactory.getResultFunction(), new DefaultGoalTest(
            SimplifiedRoadMapOfPartOfRomania.BUCHAREST),
        new MapStepCostFunction(romaniaMap));
View Full Code Here

TOP

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

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.