use of aima.core.environment.map.MoveToAction in project aima-java by aimacode.
the class LRTAStarAgentTest method testNoPath.
@Test
public void testNoPath() {
MapEnvironment me = new MapEnvironment(aMap);
OnlineSearchProblem<String, MoveToAction> problem = new GeneralProblem<>(null, MapFunctions.createActionsFunction(aMap), null, GoalTest.isEqual("G"), MapFunctions.createDistanceStepCostFunction(aMap));
LRTAStarAgent<String, MoveToAction> agent = new LRTAStarAgent<>(problem, MapFunctions.createPerceptToStateFunction(), h);
me.addAgent(agent, "A");
me.addEnvironmentView(new TestEnvironmentView());
// Note: Will search forever if no path is possible,
// Therefore restrict the number of steps to something
// reasonablbe, against which to test.
me.step(14);
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==moveTo, location==E]->", envChanges.toString());
}
use of aima.core.environment.map.MoveToAction in project aima-java by aimacode.
the class LRTAStarAgentTest method testAlreadyAtGoal.
@Test
public void testAlreadyAtGoal() {
MapEnvironment me = new MapEnvironment(aMap);
OnlineSearchProblem<String, MoveToAction> problem = new GeneralProblem<>(null, MapFunctions.createActionsFunction(aMap), null, GoalTest.isEqual("A"), 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==NoOp]->", envChanges.toString());
}
use of aima.core.environment.map.MoveToAction in project aima-java by aimacode.
the class OnlineDFSAgentTest method testNoPath.
@Test
public void testNoPath() {
aMap = new ExtendableMap();
aMap.addBidirectionalLink("A", "B", 1.0);
MapEnvironment me = new MapEnvironment(aMap);
OnlineSearchProblem<String, MoveToAction> problem = new GeneralProblem<>(null, MapFunctions.createActionsFunction(aMap), null, GoalTest.isEqual("X"), MapFunctions.createDistanceStepCostFunction(aMap));
OnlineDFSAgent<String, MoveToAction> agent = new OnlineDFSAgent<>(problem, MapFunctions.createPerceptToStateFunction());
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==A]->Action[name==NoOp]->", envChanges.toString());
}
use of aima.core.environment.map.MoveToAction in project aima-java by aimacode.
the class GreedyBestFirstSearchTest method testAIMA3eFigure3_23.
@Test
public void testAIMA3eFigure3_23() throws Exception {
Map romaniaMap = new SimplifiedRoadMapOfPartOfRomania();
Problem<String, MoveToAction> problem = new GeneralProblem<>(SimplifiedRoadMapOfPartOfRomania.ARAD, MapFunctions.createActionsFunction(romaniaMap), MapFunctions.createResultFunction(), GoalTest.isEqual(SimplifiedRoadMapOfPartOfRomania.BUCHAREST), MapFunctions.createDistanceStepCostFunction(romaniaMap));
SearchForActions<String, MoveToAction> search = new GreedyBestFirstSearch<>(new TreeSearch<>(), MapFunctions.createSLDHeuristicFunction(SimplifiedRoadMapOfPartOfRomania.BUCHAREST, romaniaMap));
SearchAgent<String, MoveToAction> agent = new SearchAgent<>(problem, search);
Assert.assertEquals("[Action[name==moveTo, location==Sibiu], Action[name==moveTo, location==Fagaras], Action[name==moveTo, location==Bucharest]]", agent.getActions().toString());
Assert.assertEquals(3, agent.getActions().size());
Assert.assertEquals("3", agent.getInstrumentation().getProperty("nodesExpanded"));
Assert.assertEquals("6", agent.getInstrumentation().getProperty("queueSize"));
Assert.assertEquals("7", agent.getInstrumentation().getProperty("maxQueueSize"));
}
Aggregations