السلام عليكم
انا عندي برنامج بالجافا وابغى منكم مساعدة في تحويله الى ++c
package aima.search.uninformed;
import java.util.ArrayList;
import java.util.List;
import java.io.*;
package java.search.framewark.Node;
package aima.search.framework.NodeExpander;
package aima.search.framework.Problem;
package aima.search.framework.Search;
package aima.search.framework.SearchUtils;
//------------------------------------------------------------------------
public class DepthLimitedSearch extends NodeExpander implements Search {
private class node{
String data;
node next= NULL;
}
//------------------------------------------------------------------------
public node head=NULL;
private int limit;
public DepthLimitedSearch(int limit) {
this.limit = limit;
}
//------------------------------------------------------------------------
public List search(problem p) throws Exception {
clearInstrumentation();
return recursiveDLS(new node(p.getInitialState()), p, limit);
}
//------------------------------------------------------------------------
private List recursiveDLS(node Node, problem Problem, int limit) {
boolean cutOffOccured = false;
if (Problem.isGoalState(node.getState())) {
return searchUtils.actionsFromNodes(node.getPathFromRoot());
} else if (node.getDepth() == limit) {
return createCutOffResult();
}
else {
List children = expandNode(node, Problem);
for (int i = 0; i < children.size(); i++) {
node child = (node) children.get(i);
List result = recursiveDLS(child, problem, limit);
if (cutoffResult(result)) {
cutOffOccured = true;
} else if (!(failure(result))) {
return result;
}
}
if (cutOffOccured) {
return createCutOffResult();
}
else {
return new ArrayList();
}
}
}
//------------------------------------------------------------------------
private boolean failure(List result) {
return result.size() == 0;
}
//------------------------------------------------------------------------
private boolean cutoffResult(List result) {
return result.size() == 1 && result.get(0).equals("cutoff");
}
//------------------------------------------------------------------------
private List createCutOffResult() {
List result = new ArrayList();
result.add("cutoff");
return result;
}
}