Search in sources :

Example 11 with SearchAgent

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

Aggregations

SearchAgent (aima.core.search.framework.SearchAgent)11 Test (org.junit.Test)11 Action (aima.core.agent.Action)8 GeneralProblem (aima.core.search.framework.problem.GeneralProblem)8 GoalTest (aima.core.search.framework.problem.GoalTest)8 MoveToAction (aima.core.environment.map.MoveToAction)5 NQueensBoard (aima.core.environment.nqueens.NQueensBoard)5 NQueensFunctions (aima.core.environment.nqueens.NQueensFunctions)5 QueenAction (aima.core.environment.nqueens.QueenAction)5 GreedyBestFirstSearch (aima.core.search.informed.GreedyBestFirstSearch)4 BidirectionalEightPuzzleProblem (aima.core.environment.eightpuzzle.BidirectionalEightPuzzleProblem)3 EightPuzzleBoard (aima.core.environment.eightpuzzle.EightPuzzleBoard)3 Map (aima.core.environment.map.Map)3 SimplifiedRoadMapOfPartOfRomania (aima.core.environment.map.SimplifiedRoadMapOfPartOfRomania)3 UniformCostSearch (aima.core.search.uninformed.UniformCostSearch)3 Node (aima.core.search.framework.Node)1 AStarSearch (aima.core.search.informed.AStarSearch)1 BreadthFirstSearch (aima.core.search.uninformed.BreadthFirstSearch)1 DepthFirstSearch (aima.core.search.uninformed.DepthFirstSearch)1 DepthLimitedSearch (aima.core.search.uninformed.DepthLimitedSearch)1