我目前有一个深度优先搜索,如下所示:
protected void algorithmLogic() {
currentNode = ((Stack<Node>) expanded).pop();
if(atGoal()) {
// Goal reached so stop
return;
}
else {
visited.add(currentNode);
if(currentNode.hasChild()) {
for(int i=currentNode.getChildren().size()-1;i>-1;i--) {
((Stack<Node>) expanded).push(currentNode.getChildren().get(i));
}
}
}
}
这是在节点上的树上工作。
是否可以以某种方式编辑此代码以执行迭代深化搜索?说限制2?我想不出一种方法来跟踪水平。