use of aima.core.environment.nqueens.NQueensFunctions in project aima-java by aimacode.
the class IterativeDeepeningSearchTest method testIterativeDeepeningSearch.
@Test
public void testIterativeDeepeningSearch() {
try {
Problem<NQueensBoard, QueenAction> problem = new GeneralProblem<>(new NQueensBoard(8), NQueensFunctions::getIFActions, NQueensFunctions::getResult, NQueensFunctions::testGoal);
SearchForActions<NQueensBoard, QueenAction> search = new IterativeDeepeningSearch<>();
List<QueenAction> actions = search.findActions(problem);
assertCorrectPlacement(actions);
Assert.assertEquals("3656", search.getMetrics().get("nodesExpanded"));
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Exception should not occur");
}
}
use of aima.core.environment.nqueens.NQueensFunctions in project aima-java by aimacode.
the class UniformCostSearchTest method testUniformCostUnSuccesfulSearch.
@Test
public void testUniformCostUnSuccesfulSearch() throws Exception {
Problem<NQueensBoard, QueenAction> problem = new GeneralProblem<>(new NQueensBoard(3), NQueensFunctions::getIFActions, NQueensFunctions::getResult, NQueensFunctions::testGoal);
SearchForActions<NQueensBoard, QueenAction> search = new UniformCostSearch<>();
SearchAgent<NQueensBoard, QueenAction> agent = new SearchAgent<>(problem, search);
List<Action> actions = agent.getActions();
Assert.assertEquals(0, actions.size());
Assert.assertEquals("6", agent.getInstrumentation().getProperty("nodesExpanded"));
// Will be 0 as did not reach goal state.
Assert.assertEquals("0", agent.getInstrumentation().getProperty("pathCost"));
}
Aggregations