Search in sources :

Example 1 with SimpleMapAgent

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

the class MapAgentTest method testNoPath.

@Test
public void testNoPath() {
    MapEnvironment me = new MapEnvironment(aMap);
    SimpleMapAgent ma = new SimpleMapAgent(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());
}
Also used : SimpleMapAgent(aima.core.environment.map.SimpleMapAgent) MapEnvironment(aima.core.environment.map.MapEnvironment) Test(org.junit.Test)

Example 2 with SimpleMapAgent

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

the class MapAgentTest method testAlreadyAtGoal.

@Test
public void testAlreadyAtGoal() {
    MapEnvironment me = new MapEnvironment(aMap);
    SimpleMapAgent ma = new SimpleMapAgent(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());
}
Also used : SimpleMapAgent(aima.core.environment.map.SimpleMapAgent) MapEnvironment(aima.core.environment.map.MapEnvironment) Test(org.junit.Test)

Example 3 with SimpleMapAgent

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

the class MapAgentTest method testNormalSearch.

@Test
public void testNormalSearch() {
    MapEnvironment me = new MapEnvironment(aMap);
    SimpleMapAgent ma = new SimpleMapAgent(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]=3:METRIC[queueSize]=1:METRIC[nodesExpanded]=3:Action[name==NoOp]:", envChanges.toString());
}
Also used : SimpleMapAgent(aima.core.environment.map.SimpleMapAgent) MapEnvironment(aima.core.environment.map.MapEnvironment) Test(org.junit.Test)

Example 4 with SimpleMapAgent

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

the class BidirectionalSearchTest method test_ABCD_BothWaysPath.

//
// Test I(A)<->(B)<->(C)<->G(D)
@Test
public void test_ABCD_BothWaysPath() {
    ExtendableMap aMap = new ExtendableMap();
    aMap.addBidirectionalLink("A", "B", 5.0);
    aMap.addBidirectionalLink("B", "C", 5.0);
    aMap.addBidirectionalLink("C", "D", 5.0);
    MapEnvironment me = new MapEnvironment(aMap);
    SimpleMapAgent ma = new SimpleMapAgent(me.getMap(), me, search, new String[] { "D" });
    me.addAgent(ma, "A");
    me.addEnvironmentView(new BDSEnvironmentView());
    me.stepUntilDone();
    Assert.assertEquals("CurrentLocation=In(A), Goal=In(D):Action[name==moveTo, location==B]:Action[name==moveTo, location==C]:Action[name==moveTo, location==D]:METRIC[pathCost]=15.0:METRIC[maxQueueSize]=2:METRIC[queueSize]=1: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 5 with SimpleMapAgent

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

the class BidirectionalSearchTest method test_AB_ReverseOnlyPath.

//
// Test I(A)<-G(B)
@Test
public void test_AB_ReverseOnlyPath() {
    ExtendableMap aMap = new ExtendableMap();
    aMap.addUnidirectionalLink("B", "A", 5.0);
    MapEnvironment me = new MapEnvironment(aMap);
    SimpleMapAgent ma = new SimpleMapAgent(me.getMap(), me, search, new String[] { "B" });
    me.addAgent(ma, "A");
    me.addEnvironmentView(new BDSEnvironmentView());
    me.stepUntilDone();
    Assert.assertEquals("CurrentLocation=In(A), Goal=In(B):Action[name==NoOp]:METRIC[pathCost]=0:METRIC[maxQueueSize]=2:METRIC[queueSize]=0:METRIC[nodesExpanded]=2: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

SimpleMapAgent (aima.core.environment.map.SimpleMapAgent)20 MapEnvironment (aima.core.environment.map.MapEnvironment)19 Test (org.junit.Test)19 ExtendableMap (aima.core.environment.map.ExtendableMap)15 UniformCostSearch (aima.core.search.uninformed.UniformCostSearch)3 MoveToAction (aima.core.environment.map.MoveToAction)2 Before (org.junit.Before)1