use of aima.core.environment.map.MapEnvironment in project aima-java by aimacode.
the class MapAgentView method getAgentLocs.
/** Returns the locations of all agents. */
protected List<String> getAgentLocs() {
List<String> result = new ArrayList<String>();
MapEnvironment mEnv = getMapEnv();
for (Agent a : mEnv.getAgents()) result.add(mEnv.getAgentLocation(a));
return result;
}
use of aima.core.environment.map.MapEnvironment 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());
}
use of aima.core.environment.map.MapEnvironment 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());
}
use of aima.core.environment.map.MapEnvironment 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());
}
use of aima.core.environment.map.MapEnvironment in project aima-java by aimacode.
the class LRTAStarAgentTest method testNormalSearch.
@Test
public void testNormalSearch() {
MapEnvironment me = new MapEnvironment(aMap);
OnlineSearchProblem<String, MoveToAction> problem = new GeneralProblem<>(null, MapFunctions.createActionsFunction(aMap), null, GoalTest.isEqual("F"), MapFunctions.createDistanceStepCostFunction(aMap));
LRTAStarAgent<String, MoveToAction> agent = new LRTAStarAgent<>(problem, MapFunctions.createPerceptToStateFunction(), h);
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());
}
Aggregations