Search in sources :

Example 26 with Action

use of aima.core.agent.Action 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

Action (aima.core.agent.Action)26 Test (org.junit.Test)12 SearchAgent (aima.core.search.framework.SearchAgent)8 NoOpAction (aima.core.agent.impl.NoOpAction)6 GeneralProblem (aima.core.search.framework.problem.GeneralProblem)6 EightPuzzleBoard (aima.core.environment.eightpuzzle.EightPuzzleBoard)5 NQueensBoard (aima.core.environment.nqueens.NQueensBoard)5 NQueensFunctions (aima.core.environment.nqueens.NQueensFunctions)5 QueenAction (aima.core.environment.nqueens.QueenAction)5 GoalTest (aima.core.search.framework.problem.GoalTest)5 ArrayList (java.util.ArrayList)4 DynamicAction (aima.core.agent.impl.DynamicAction)3 BidirectionalEightPuzzleProblem (aima.core.environment.eightpuzzle.BidirectionalEightPuzzleProblem)3 Agent (aima.core.agent.Agent)2 Percept (aima.core.agent.Percept)2 MoveToAction (aima.core.environment.map.MoveToAction)2 Climb (aima.core.environment.wumpusworld.action.Climb)2 Grab (aima.core.environment.wumpusworld.action.Grab)2 TurnLeft (aima.core.environment.wumpusworld.action.TurnLeft)2 GreedyBestFirstSearch (aima.core.search.informed.GreedyBestFirstSearch)2