2

好的,所以我有一个叫做 CuFrog 的谜题,它包括在每个位置用一个数字填充一个 3x3x3 的立方体,但是当从一个位置移动到另一个位置时会跳过一个位置。例如,考虑一个扁平的立方体,第 1 侧 (1,1) 右侧的有效位置将是第 1 侧的 (3,1)。

所以我在 Prolog 中使用约束来执行此操作,并且我已经给出了每个变量的域(1 到 54),我已经说过它们必须都是不同的,并且对于每个位置,集合中的一个位置right-left-down-up 必须是该位置的当前值 + 1。

另外,我已经给出了这个谜题的入口点,这意味着我已经将数字 1 放在了第一个位置。

问题是,当我标记变量时,SICStus 没有找到我的答案。:( 看来我一定是在某处遗漏了限制,或者我做错了什么。有人可以帮忙吗?

谢谢。

4

1 回答 1

2

So you say the CLP(FD) doesn't find a solution. Do you mean it terminates with "no" or do you mean it doesn't terminate?

The problem looks like a Hamiltonian path problem. It could be that the search needs exponential time, and simply doesn't terminate in practical time.

In this particular case, giving restrictions like symmetry breaking heuristics, could in fact reduce the search time! For example from your starting point, you could fix the search in 2 directions, the other directions can be derived later.

So if the answer is "No", this means too many restrictions. If the answer is that it doesn't terminate, this means not enough restrictions or impossible to practically solve.

Despite all the brute force you put into searching a path, it might later turn out that a solution is systematic. Or you might get the idea by yourself.

Bye

于 2015-09-01T18:17:14.287 回答