【发布时间】:2014-07-24 11:33:37
【问题描述】:
根据我的问题Java algorithm filling cells like an `Android - Flow` game
假设我有四个点(两对),我如何检查是否存在填充所有游戏板的点之间的路径组合?
类似于右图,但有四个点(两对)。
我需要检查是否可以用两条弧线(路径)填充所有游戏板。
现在我在填充结构后停止了:
private static void buildGrid(int gridResolution) {
for (int i = 1; i < 3; i++) {
for (int j = 0; j < gridResolution; j++) {
Node node = new Node();
if (startPoint1.x == i && startPoint1.y == j) {
node.point = new PointM(new Point(i, j), 1);
startNode1 = node;
} else if (startPoint2.x == i && startPoint2.y == j) {
node.point = new PointM(new Point(i, j), 1);
startNode2 = node;
} else if (endPoint1.x == i && endPoint1.y == j) {
node.point = new PointM(new Point(i, j), 2);
endNode1 = node;
} else if (endPoint2.x == i && endPoint2.y == j) {
node.point = new PointM(new Point(i, j), 2);
endNode2 = node;
} else {
node.point = new PointM(new Point(i, j), 0);
}
nodes[i][j] = node;
Node leftNode = getLeftNode(i, j);
Node topNode = getTopNode(i, j);
if (leftNode != null) {
node.left = leftNode;
leftNode.right = node;
}
if (topNode != null) {
node.top = topNode;
topNode.bottom = node.top;
}
}
}
}
private static Node getTopNode(int i, int j) {
return nodes[i - 1][j];
}
private static Node getLeftNode(int i, int j) {
if (j - 1 > 0)
return nodes[i][j - 1];
else return null;
}
private static class Node {
public PointM point;
public Node left;
public Node right;
public Node top;
public Node bottom;
public boolean isChecked;
}
我不知道在那之后我需要做什么。我停留在这一刻。最好并且会绕过这个表。也许是什么算法?
【问题讨论】:
-
如果你能解释你的反对意见,我将不胜感激......
-
请发布您遇到问题的具体代码。
-
@AndrewArnold 我在问题顶部提供了一个代码链接。
-
不,您提供了另一个问题的链接。你需要把相关代码放在这个问题中。
-
@AndrewArnold 上帝...这只是复制粘贴操作...