Skip to content

Commit b3793e8

Browse files
Update README.md
1 parent 106b3e1 commit b3793e8

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

aima-core/README.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,15 @@ To actually search you need to:
7777

7878
A good example (from the NQueens Demo) is:
7979
```java
80-
private static void nQueensWithBreadthFirstSearch() {
81-
try {
82-
System.out.println("\nNQueensDemo 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
```
9491
For further information about code design, see [Wiki2](https://github.com/aimacode/aima-java/wiki/AIMA3e-Search-Framework).

0 commit comments

Comments
 (0)