Search in sources :

Example 1 with IterativeDeepeningSearch

use of aima.core.search.uninformed.IterativeDeepeningSearch 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");
    }
}
Also used : NQueensFunctions(aima.core.environment.nqueens.NQueensFunctions) QueenAction(aima.core.environment.nqueens.QueenAction) IterativeDeepeningSearch(aima.core.search.uninformed.IterativeDeepeningSearch) NQueensBoard(aima.core.environment.nqueens.NQueensBoard) GeneralProblem(aima.core.search.framework.problem.GeneralProblem) Test(org.junit.Test)

Aggregations

NQueensBoard (aima.core.environment.nqueens.NQueensBoard)1 NQueensFunctions (aima.core.environment.nqueens.NQueensFunctions)1 QueenAction (aima.core.environment.nqueens.QueenAction)1 GeneralProblem (aima.core.search.framework.problem.GeneralProblem)1 IterativeDeepeningSearch (aima.core.search.uninformed.IterativeDeepeningSearch)1 Test (org.junit.Test)1