use of aima.core.environment.map.ExtendableMap in project aima-java by aimacode.
the class BidirectionalSearchTest method test_ABCDE_OriginalOnlyPath.
//
// Test I(A)->(B)->(C)<->(D)<->G(E)
@Test
public void test_ABCDE_OriginalOnlyPath() {
ExtendableMap aMap = new ExtendableMap();
aMap.addBidirectionalLink("A", "B", 5.0);
aMap.addUnidirectionalLink("B", "C", 5.0);
aMap.addBidirectionalLink("C", "D", 5.0);
aMap.addBidirectionalLink("D", "E", 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==moveTo, location==B]:Action[name==moveTo, location==C]:Action[name==moveTo, location==D]:Action[name==moveTo, location==E]:METRIC[pathCost]=20.0:METRIC[maxQueueSize]=2:METRIC[queueSize]=1:METRIC[nodesExpanded]=5:Action[name==NoOp]:", envChanges.toString());
}
use of aima.core.environment.map.ExtendableMap in project aima-java by aimacode.
the class BidirectionalSearchTest method test_ABCDEF_OriginalFirst.
/**
* <code>
* Test I(A)<->(B)<->(C)<->(D)<->(E)<->(F)<->(G)<->G(H)
* | +
* --------------------------------------
* </code>
*/
@Test
public void test_ABCDEF_OriginalFirst() {
ExtendableMap aMap = new ExtendableMap();
aMap.addBidirectionalLink("A", "B", 5.0);
aMap.addBidirectionalLink("B", "C", 5.0);
aMap.addBidirectionalLink("C", "D", 5.0);
aMap.addBidirectionalLink("D", "E", 5.0);
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);
SimpleMapAgent ma = new SimpleMapAgent(me.getMap(), me, search, 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]=2:METRIC[queueSize]=2:METRIC[nodesExpanded]=3:Action[name==NoOp]:", envChanges.toString());
}
use of aima.core.environment.map.ExtendableMap in project aima-java by aimacode.
the class BidirectionalSearchTest method test_ABC_BothWaysPath.
//
// Test I(A)<->(B)<->G(C)
@Test
public void test_ABC_BothWaysPath() {
ExtendableMap aMap = new ExtendableMap();
aMap.addBidirectionalLink("A", "B", 5.0);
aMap.addBidirectionalLink("B", "C", 5.0);
MapEnvironment me = new MapEnvironment(aMap);
SimpleMapAgent ma = new SimpleMapAgent(me.getMap(), me, search, new String[] { "C" });
me.addAgent(ma, "A");
me.addEnvironmentView(new BDSEnvironmentView());
me.stepUntilDone();
Assert.assertEquals("CurrentLocation=In(A), Goal=In(C):Action[name==moveTo, location==B]:Action[name==moveTo, location==C]:METRIC[pathCost]=10.0:METRIC[maxQueueSize]=2:METRIC[queueSize]=1:METRIC[nodesExpanded]=3:Action[name==NoOp]:", envChanges.toString());
}
use of aima.core.environment.map.ExtendableMap in project aima-java by aimacode.
the class MapAgentTest method setUp.
@Before
public void setUp() {
aMap = new ExtendableMap();
aMap.addBidirectionalLink("A", "B", 5.0);
aMap.addBidirectionalLink("A", "C", 6.0);
aMap.addBidirectionalLink("B", "C", 4.0);
aMap.addBidirectionalLink("C", "D", 7.0);
aMap.addUnidirectionalLink("B", "E", 14.0);
envChanges = new StringBuffer();
}
use of aima.core.environment.map.ExtendableMap in project aima-java by aimacode.
the class MapEnvironmentTest method setUp.
@Before
public void setUp() {
ExtendableMap aMap = new ExtendableMap();
aMap.addBidirectionalLink("A", "B", 5.0);
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 SimpleMapAgent(me.getMap(), me, new UniformCostSearch(), new String[] { "A" });
}
Aggregations