File tree Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -77,18 +77,15 @@ To actually search you need to:
7777
7878A good example (from the NQueens Demo) is:
7979``` java
80- private static void nQueensWithBreadthFirstSearch() {
81- try {
82- System . out. println(" \n NQueensDemo BFS -->" );
83- Problem<NQueensBoard , QueenAction > problem =
84- NQueensFunctions . createIncrementalFormulationProblem(boardSize);
85- SearchForActions<NQueensBoard , QueenAction > search = new BreadthFirstSearch<> (new TreeSearch<> ());
86- SearchAgent<Object , NQueensBoard , QueenAction > agent = new SearchAgent<> (problem, search);
87- printActions(agent. getActions());
88- printInstrumentation(agent. getInstrumentation());
89- } catch (Exception e) {
90- e. printStackTrace();
91- }
80+ private static void solveNQueensWithBreadthFirstSearch() {
81+ System . out. println(" \n --- NQueensDemo BFS ---" );
82+
83+ Problem<NQueensBoard , QueenAction > problem = NQueensFunctions . createIncrementalFormulationProblem(boardSize);
84+ SearchForActions<NQueensBoard , QueenAction > search = new BreadthFirstSearch<> (new GraphSearch<> ());
85+ Optional<List<QueenAction > > actions = search. findActions(problem);
86+
87+ actions. ifPresent(qActions - > qActions. forEach(System . out:: println));
88+ System . out. println(search. getMetrics());
9289}
9390```
9491For further information about code design, see [ Wiki2] ( https://github.com/aimacode/aima-java/wiki/AIMA3e-Search-Framework ) .
You can’t perform that action at this time.
0 commit comments