Skip to content

Commit fa740c8

Browse files
committed
Search interface and IterativeDeepening cleaned up.
1 parent c2a7ff5 commit fa740c8

25 files changed

+385
-414
lines changed

aima-core/src/main/java/aima/core/environment/map/MapAgent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ protected Problem formulateProblem(Object goal) {
102102
protected List<Action> search(Problem problem) {
103103
List<Action> result = new ArrayList<Action>();
104104
try {
105-
result.addAll(search.search(problem));
105+
result.addAll(search.findActions(problem));
106106
} catch (Exception ex) {
107107
ex.printStackTrace();
108108
}

aima-core/src/main/java/aima/core/environment/map/SimpleMapAgent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ protected Problem formulateProblem(Object goal) {
9999
protected List<Action> search(Problem problem) {
100100
List<Action> result = new ArrayList<Action>();
101101
try {
102-
result.addAll(search.search(problem));
102+
result.addAll(search.findActions(problem));
103103
} catch (Exception ex) {
104104
ex.printStackTrace();
105105
}

aima-core/src/main/java/aima/core/search/framework/CutOffIndicatorAction.java

Lines changed: 0 additions & 26 deletions
This file was deleted.

aima-core/src/main/java/aima/core/search/framework/PrioritySearch.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,16 @@ public PrioritySearch(QueueSearch impl, Comparator<Node> comp) {
2626
}
2727

2828
@Override
29-
public List<Action> search(Problem p) {
29+
public List<Action> findActions(Problem p) {
3030
implementation.getNodeExpander().useParentLinks(true);
31-
Node node = implementation.search(p, QueueFactory.<Node>createPriorityQueue(comparator));
31+
Node node = implementation.findNode(p, QueueFactory.<Node>createPriorityQueue(comparator));
3232
return node == null ? SearchUtils.failure() : SearchUtils.getSequenceOfActions(node);
3333
}
3434

3535
@Override
36-
public Object searchState(Problem p) {
36+
public Object findState(Problem p) {
3737
implementation.getNodeExpander().useParentLinks(false);
38-
Node node = implementation.search(p, QueueFactory.<Node>createPriorityQueue(comparator));
38+
Node node = implementation.findNode(p, QueueFactory.<Node>createPriorityQueue(comparator));
3939
return node == null ? null : node.getState();
4040
}
4141

aima-core/src/main/java/aima/core/search/framework/SearchAgent.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class SearchAgent extends AbstractAgent {
2222
private Metrics searchMetrics;
2323

2424
public SearchAgent(Problem p, SearchForActions search) throws Exception {
25-
actionList = search.search(p);
25+
actionList = search.findActions(p);
2626
actionIterator = actionList.iterator();
2727
searchMetrics = search.getMetrics();
2828
}

aima-core/src/main/java/aima/core/search/framework/SearchForActions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public interface SearchForActions {
2828
* containing a single NoOp Action if already at the goal, or an
2929
* empty list if the goal could not be found.
3030
*/
31-
List<Action> search(Problem p);
31+
List<Action> findActions(Problem p);
3232

3333
/**
3434
* Returns all the metrics of the search.

aima-core/src/main/java/aima/core/search/framework/SearchForStates.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public interface SearchForStates {
2121
*
2222
* @return a state.
2323
*/
24-
Object searchState(Problem p);
24+
Object findState(Problem p);
2525

2626
/**
2727
* Returns all the metrics of the search.

aima-core/src/main/java/aima/core/search/framework/qsearch/BidirectionalSearch.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public BidirectionalSearch(NodeExpander nodeExpander) {
7979
* containing a single NoOp Action if already at the goal, or an
8080
* empty list if the goal could not be found.
8181
*/
82-
public Node search(Problem problem, Queue<Node> frontier) {
82+
public Node findNode(Problem problem, Queue<Node> frontier) {
8383
assert (problem instanceof BidirectionalProblem);
8484

8585
nodeExpander.useParentLinks(true); // bidirectional search needs parents!

aima-core/src/main/java/aima/core/search/framework/qsearch/GraphSearch.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* Figure 3.7 An informal description of the general graph-search algorithm.
2929
* <br>
3030
* This implementation is based on the template method
31-
* {@link QueueSearch#search(Problem, Queue)} of the superclass and provides
31+
* {@link QueueSearch#findNode(Problem, Queue)} of the superclass and provides
3232
* implementations for the needed primitive operations. In contrast to the code
3333
* above, here, nodes resulting from node expansion are added to the frontier
3434
* even if nodes for the same states already exist there. This makes it possible
@@ -56,10 +56,10 @@ public GraphSearch(NodeExpander nodeExpander) {
5656
* {@link QueueSearch}.
5757
*/
5858
@Override
59-
public Node search(Problem problem, Queue<Node> frontier) {
59+
public Node findNode(Problem problem, Queue<Node> frontier) {
6060
// initialize the explored set to be empty
6161
explored.clear();
62-
return super.search(problem, frontier);
62+
return super.findNode(problem, frontier);
6363
}
6464

6565
/**

aima-core/src/main/java/aima/core/search/framework/qsearch/GraphSearchBFS.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* Figure 3.7 An informal description of the general graph-search algorithm.
2929
* <br>
3030
* This implementation is based on the template method
31-
* {@link QueueSearch#search(Problem, Queue)} of the superclass and
31+
* {@link QueueSearch#findNode(Problem, Queue)} of the superclass and
3232
* provides implementations for the needed primitive operations. It is the most
3333
* efficient variant of graph search for breadth first search. But don't expect
3434
* shortest paths in combination with priority queue frontiers.
@@ -56,11 +56,11 @@ public GraphSearchBFS(NodeExpander nodeExpander) {
5656
* <code>QueSearch</code>
5757
*/
5858
@Override
59-
public Node search(Problem problem, Queue<Node> frontier) {
59+
public Node findNode(Problem problem, Queue<Node> frontier) {
6060
// Initialize the explored set to be empty
6161
explored.clear();
6262
frontierStates.clear();
63-
return super.search(problem, frontier);
63+
return super.findNode(problem, frontier);
6464
}
6565

6666
/**

0 commit comments

Comments
 (0)