package MyLesson.HorseProblem;
import java.util.Random;
import java.util.Vector;
public class HorseProblem3 {
public static void main(String[] args) {
Random rnd = new Random();
node root = new node(null, rnd.nextInt(8), rnd.nextInt(8));
node leaf = depthFirstSearch(root);
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
System.out.print( (leaf.Grid[i][j] + " ").substring(0, 4));
}
System.out.println();
}
}
public static node depthFirstSearch(node curNode) {
if (curNode.depth==64) return curNode;
curNode.setSons();
node[] sons = curNode.getSons();
if (sons == null) return null;
for (int i = 0; i < sons.length; i++) {
//if (sons[i].depth==64) return sons[i];
node n = depthFirstSearch(sons[i]);
if (n != null) return n;
}
return null;
}
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余3页未读,立即下载