Skip to content

Commit

Permalink
Some variables renamed (following textbook name conventions).
Browse files Browse the repository at this point in the history
  • Loading branch information
ruediger.lunde@gmail.com committed Apr 22, 2016
1 parent e447ca8 commit 90fc4d5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Expand Up @@ -40,7 +40,7 @@ public static interface NodeListener {
* specified problem. * specified problem.
*/ */
public static List<Node> expandNode(Node node, Problem problem) { public static List<Node> expandNode(Node node, Problem problem) {
List<Node> childNodes = new ArrayList<Node>(); List<Node> successors = new ArrayList<Node>();


for (NodeListener listener : nodeListeners) for (NodeListener listener : nodeListeners)
listener.onNodeExpanded(node); listener.onNodeExpanded(node);
Expand All @@ -53,9 +53,9 @@ public static List<Node> expandNode(Node node, Problem problem) {
Object successorState = resultFunction.result(node.getState(), action); Object successorState = resultFunction.result(node.getState(), action);


double stepCost = stepCostFunction.c(node.getState(), action, successorState); double stepCost = stepCostFunction.c(node.getState(), action, successorState);
childNodes.add(new Node(successorState, node, action, stepCost)); successors.add(new Node(successorState, node, action, stepCost));
} }
return childNodes; return successors;
} }


/** /**
Expand Down
Expand Up @@ -103,16 +103,16 @@ public List<Action> search(Problem problem, Queue<Node> frontier) {
// expand the chosen node, adding the resulting nodes to the // expand the chosen node, adding the resulting nodes to the
// frontier // frontier
metrics.incrementInt(METRIC_NODES_EXPANDED); metrics.incrementInt(METRIC_NODES_EXPANDED);
for (Node cn : SearchUtils.expandNode(nodeToExpand, problem)) { for (Node s : SearchUtils.expandNode(nodeToExpand, problem)) {
ExtendedNode childNode = new ExtendedNode(cn, nodeToExpand.getProblemIndex()); ExtendedNode successor = new ExtendedNode(s, nodeToExpand.getProblemIndex());
if (!isReverseActionTestEnabled || nodeToExpand.getProblemIndex() == ORG_P_IDX if (!isReverseActionTestEnabled || nodeToExpand.getProblemIndex() == ORG_P_IDX
|| getReverseAction(orgP, childNode) != null) { || getReverseAction(orgP, successor) != null) {


if (checkGoalBeforeAddingToFrontier if (checkGoalBeforeAddingToFrontier
&& (nodeFromOtherProblem = getCorrespondingNodeFromOtherProblem(childNode)) != null) && (nodeFromOtherProblem = getCorrespondingNodeFromOtherProblem(successor)) != null)
return getSolution(orgP, childNode, nodeFromOtherProblem); return getSolution(orgP, successor, nodeFromOtherProblem);


insertIntoFrontier(childNode); insertIntoFrontier(successor);
} }
} }
} }
Expand Down
Expand Up @@ -70,12 +70,12 @@ public List<Action> search(Problem problem, Queue<Node> frontier) {
// expand the chosen node, adding the resulting nodes to the // expand the chosen node, adding the resulting nodes to the
// frontier // frontier
metrics.incrementInt(METRIC_NODES_EXPANDED); metrics.incrementInt(METRIC_NODES_EXPANDED);
for (Node childNode : SearchUtils.expandNode(nodeToExpand, problem)) { for (Node successor : SearchUtils.expandNode(nodeToExpand, problem)) {
if (checkGoalBeforeAddingToFrontier) { if (checkGoalBeforeAddingToFrontier) {
if (SearchUtils.isGoalState(problem, childNode)) if (SearchUtils.isGoalState(problem, successor))
return getSolution(childNode); return getSolution(successor);
} }
insertIntoFrontier(childNode); insertIntoFrontier(successor);
} }
} }
// if the frontier is empty then return failure // if the frontier is empty then return failure
Expand Down

0 comments on commit 90fc4d5

Please sign in to comment.