Algorithm 求解魔方问题的prolog-BFS算法

Algorithm 求解魔方问题的prolog-BFS算法,algorithm,search,tree,prolog,breadth-first-search,Algorithm,Search,Tree,Prolog,Breadth First Search,我想知道如何为我函数的输入参数RubikCube运行BFS算法。到目前为止,我已经创建了函数rotateUp(cubeIn,cubeOut),rotateDown(cubeIn,cubeut2),rotateFront(cubeIn,cubeOut),rotateBack(cubeIn,cubeOut),rotateLeft(cubeIn,cubeOut),rotateRight(cubeIn,cubeOut)来旋转魔方的每一面 现在,我将运行一些递归函数,在这里我可以以各种可能的方式旋转我的立

我想知道如何为我函数的输入参数RubikCube运行BFS算法。到目前为止,我已经创建了函数
rotateUp(cubeIn,cubeOut),rotateDown(cubeIn,cubeut2),rotateFront(cubeIn,cubeOut),rotateBack(cubeIn,cubeOut),rotateLeft(cubeIn,cubeOut),rotateRight(cubeIn,cubeOut)
来旋转魔方的每一面

现在,我将运行一些递归函数,在这里我可以以各种可能的方式旋转我的立方体,然后,如果魔方被解了,我将进行chceck

我已经尝试过这个解决方案,但它只会越来越深:

bfs(cubeIn) :-
        rotateUp(cubeIn, cubeOut1), bfs(cubeOut1),
        rotateDown(cubeIn, cubeOut2), bfs(cubeOut2),
        rotateFront(cubeIn, cubeOut3), bfs(cubeOut3),
        rotateBack(cubeIn, cubeOut4), bfs(cubeOut4),
        rotateLeft(cubeIn, cubeOut5), bfs(cubeOut5),
        rotateRight(cubeIn, cubeOut6), bfs(cubeOut6).
所以我想为我的魔方问题实现BFS算法,我做了这个:

bfs(cubeIn) :-
        rotateUp(cubeIn, cubeOut1),
        rotateDown(cubeIn, cubeOut2),
        rotateFront(cubeIn, cubeOut3),
        rotateBack(cubeIn, cubeOut4),
        rotateLeft(cubeIn, cubeOut5),
        rotateRight(cubeIn, cubeOut6),
        bfs(cubeOut1),bfs(cubeOut2),bfs(cubeOut3),
        bfs(cubeOut4),bfs(cubeOut5),bfs(cubeOut6).
但最终它仍然不能像BFS那样工作。
你不知道我做错了什么吗?

??变量必须启动uppercase@CapelliC假设它是一个伪代码,我在bfs()中有更多的操作,我只是想展示我将要创建的内容。那么,如何传递状态呢?当然,您可以使用一些hack-binding常量,比如cubeOut1,将其绑定到实际的数据结构,但似乎完全没有用。。。也许你应该展示类似于
bfs(CubeIn):-rotateUp(CubeIn,CubeOut1),rotateDown(CubeOut1,CubeOut2),…
首先只定义一个转换,然后使用我不使用bfs进行解算,但这可能会给你一些想法