Search in sources :

Example 21 with ExtendableMap

use of aima.core.environment.map.ExtendableMap in project aima-java by aimacode.

the class BidirectionalSearchTest method test_ABCDE_ReverseOnlyPath.

// Test I(A)<->(B)<->(C)<-(D)<-G(E)
@Test
public void test_ABCDE_ReverseOnlyPath() {
    ExtendableMap aMap = new ExtendableMap();
    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);
    SimpleMapAgent ma = new SimpleMapAgent(me.getMap(), me, search, 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:METRIC[maxQueueSize]=2:METRIC[queueSize]=0:METRIC[nodesExpanded]=4:Action[name==NoOp]:", envChanges.toString());
}
Also used : SimpleMapAgent(aima.core.environment.map.SimpleMapAgent) MapEnvironment(aima.core.environment.map.MapEnvironment) ExtendableMap(aima.core.environment.map.ExtendableMap) Test(org.junit.Test)

Example 22 with ExtendableMap

use of aima.core.environment.map.ExtendableMap in project aima-java by aimacode.

the class BidirectionalSearchTest method test_A_StartingAtGoal.

//
// Test IG(A)
@Test
public void test_A_StartingAtGoal() {
    ExtendableMap aMap = new ExtendableMap();
    MapEnvironment me = new MapEnvironment(aMap);
    SimpleMapAgent ma = new SimpleMapAgent(me.getMap(), me, search, new String[] { "A" });
    me.addAgent(ma, "A");
    me.addEnvironmentView(new BDSEnvironmentView());
    me.stepUntilDone();
    Assert.assertEquals("CurrentLocation=In(A), Goal=In(A):Action[name==NoOp]:METRIC[pathCost]=0.0:METRIC[maxQueueSize]=0:METRIC[queueSize]=0:METRIC[nodesExpanded]=0:Action[name==NoOp]:", envChanges.toString());
}
Also used : SimpleMapAgent(aima.core.environment.map.SimpleMapAgent) MapEnvironment(aima.core.environment.map.MapEnvironment) ExtendableMap(aima.core.environment.map.ExtendableMap) Test(org.junit.Test)

Aggregations

ExtendableMap (aima.core.environment.map.ExtendableMap)22 MapEnvironment (aima.core.environment.map.MapEnvironment)17 Test (org.junit.Test)16 SimpleMapAgent (aima.core.environment.map.SimpleMapAgent)15 Before (org.junit.Before)6 MoveToAction (aima.core.environment.map.MoveToAction)2 GeneralProblem (aima.core.search.framework.problem.GeneralProblem)2 GoalTest (aima.core.search.framework.problem.GoalTest)2 OnlineDFSAgent (aima.core.search.online.OnlineDFSAgent)2 UniformCostSearch (aima.core.search.uninformed.UniformCostSearch)1