Package aima.core.environment.map

Examples of aima.core.environment.map.MapEnvironment


  public void test_ABC_ReverseOnlyPath() {
    ExtendableMap aMap = new ExtendableMap();
    aMap.addUnidirectionalLink("B", "A", 5.0);
    aMap.addUnidirectionalLink("C", "B", 5.0);

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

    Assert.assertEquals(
        "CurrentLocation=In(A), Goal=In(C):Action[name==NoOp]:METRIC[pathCost]=0.0:METRIC[maxQueueSize]=2:METRIC[queueSize]=0:METRIC[nodesExpanded]=4:Action[name==NoOp]:",
        envChanges.toString());
View Full Code Here


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

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

    Assert.assertEquals(
        "CurrentLocation=In(A), Goal=In(E):Action[name==NoOp]:METRIC[pathCost]=0.0:METRIC[maxQueueSize]=2:METRIC[queueSize]=0:METRIC[nodesExpanded]=8:Action[name==NoOp]:",
        envChanges.toString());
View Full Code Here

        new AStarEvaluationFunction(heuristicFunction));
  }

  @Test
  public void testStartingAtGoal() {
    MapEnvironment me = new MapEnvironment(aMap);
    MapAgent ma = new MapAgent(me.getMap(), me, recursiveBestFirstSearch,
        new String[] { SimplifiedRoadMapOfPartOfRomania.BUCHAREST });

    me.addAgent(ma, SimplifiedRoadMapOfPartOfRomania.BUCHAREST);
    me.addEnvironmentView(new TestEnvironmentView());
    me.stepUntilDone();

    Assert.assertEquals(
        "CurrentLocation=In(Bucharest), Goal=In(Bucharest):Action[name==NoOp]:METRIC[pathCost]=0.0:METRIC[maxRecursiveDepth]=0:METRIC[nodesExpanded]=0:Action[name==NoOp]:",
        envChanges.toString());
  }
View Full Code Here

        envChanges.toString());
  }

  @Test
  public void testAIMA3eFigure3_27() {
    MapEnvironment me = new MapEnvironment(aMap);
    MapAgent ma = new MapAgent(me.getMap(), me, recursiveBestFirstSearch,
        new String[] { SimplifiedRoadMapOfPartOfRomania.BUCHAREST });

    me.addAgent(ma, SimplifiedRoadMapOfPartOfRomania.ARAD);
    me.addEnvironmentView(new TestEnvironmentView());
    me.stepUntilDone();

    Assert.assertEquals(
        "CurrentLocation=In(Arad), Goal=In(Bucharest):Action[name==moveTo, location==Sibiu]:Action[name==moveTo, location==RimnicuVilcea]:Action[name==moveTo, location==Pitesti]:Action[name==moveTo, location==Bucharest]:METRIC[pathCost]=418.0:METRIC[maxRecursiveDepth]=4:METRIC[nodesExpanded]=6:Action[name==NoOp]:",
        envChanges.toString());
  }
View Full Code Here

    aMap.addBidirectionalLink("A", "C", 6.0);
    aMap.addBidirectionalLink("B", "C", 4.0);
    aMap.addBidirectionalLink("C", "D", 7.0);
    aMap.addUnidirectionalLink("B", "E", 14.0);

    me = new MapEnvironment(aMap);
    ma = new MapAgent(me.getMap(), me, new UniformCostSearch(),
        new String[] { "A" });
  }
View Full Code Here

    envChanges = new StringBuffer();
  }

  @Test
  public void testAlreadyAtGoal() {
    MapEnvironment me = new MapEnvironment(aMap);
    MapAgent ma = new MapAgent(me.getMap(), me, new UniformCostSearch(),
        new String[] { "A" });
    me.addAgent(ma, "A");
    me.addEnvironmentView(new TestEnvironmentView());
    me.stepUntilDone();

    Assert.assertEquals(
        "CurrentLocation=In(A), Goal=In(A):Action[name==NoOp]:METRIC[pathCost]=0.0:METRIC[maxQueueSize]=1:METRIC[queueSize]=0:METRIC[nodesExpanded]=0:Action[name==NoOp]:",
        envChanges.toString());
  }
View Full Code Here

        envChanges.toString());
  }

  @Test
  public void testNormalSearch() {
    MapEnvironment me = new MapEnvironment(aMap);
    MapAgent ma = new MapAgent(me.getMap(), me, new UniformCostSearch(),
        new String[] { "D" });
    me.addAgent(ma, "A");
    me.addEnvironmentView(new TestEnvironmentView());
    me.stepUntilDone();

    Assert.assertEquals(
        "CurrentLocation=In(A), Goal=In(D):Action[name==moveTo, location==C]:Action[name==moveTo, location==D]:METRIC[pathCost]=13.0:METRIC[maxQueueSize]=2:METRIC[queueSize]=1:METRIC[nodesExpanded]=3:Action[name==NoOp]:",
        envChanges.toString());
  }
View Full Code Here

        envChanges.toString());
  }

  @Test
  public void testNoPath() {
    MapEnvironment me = new MapEnvironment(aMap);
    MapAgent ma = new MapAgent(me.getMap(), me, new UniformCostSearch(),
        new String[] { "A" });
    me.addAgent(ma, "E");
    me.addEnvironmentView(new TestEnvironmentView());
    me.stepUntilDone();

    Assert.assertEquals(
        "CurrentLocation=In(E), Goal=In(A):Action[name==NoOp]:METRIC[pathCost]=0:METRIC[maxQueueSize]=1:METRIC[queueSize]=0:METRIC[nodesExpanded]=1:Action[name==NoOp]:",
        envChanges.toString());
  }
View Full Code Here

    envChanges = new StringBuffer();
  }

  @Test
  public void testAlreadyAtGoal() {
    MapEnvironment me = new MapEnvironment(aMap);
    LRTAStarAgent agent = new LRTAStarAgent(new OnlineSearchProblem(
        MapFunctionFactory.getActionsFunction(aMap),
        new DefaultGoalTest("A"), new MapStepCostFunction(aMap)),
        MapFunctionFactory.getPerceptToStateFunction(), hf);
    me.addAgent(agent, "A");
    me.addEnvironmentView(new TestEnvironmentView());
    me.stepUntilDone();

    Assert.assertEquals("Action[name==NoOp]->", envChanges.toString());
  }
View Full Code Here

    Assert.assertEquals("Action[name==NoOp]->", envChanges.toString());
  }

  @Test
  public void testNormalSearch() {
    MapEnvironment me = new MapEnvironment(aMap);
    LRTAStarAgent agent = new LRTAStarAgent(new OnlineSearchProblem(
        MapFunctionFactory.getActionsFunction(aMap),
        new DefaultGoalTest("F"), new MapStepCostFunction(aMap)),
        MapFunctionFactory.getPerceptToStateFunction(), hf);
    me.addAgent(agent, "A");
    me.addEnvironmentView(new TestEnvironmentView());
    me.stepUntilDone();

    Assert.assertEquals(
        "Action[name==moveTo, location==B]->Action[name==moveTo, location==A]->Action[name==moveTo, location==B]->Action[name==moveTo, location==C]->Action[name==moveTo, location==B]->Action[name==moveTo, location==C]->Action[name==moveTo, location==D]->Action[name==moveTo, location==C]->Action[name==moveTo, location==D]->Action[name==moveTo, location==E]->Action[name==moveTo, location==D]->Action[name==moveTo, location==E]->Action[name==moveTo, location==F]->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.