prolog继承人状态公理错误:超出本地堆栈

时间:2017-11-17 11:01:42

标签: prolog wumpus-world

我正试图为一个在4x4网格中移动(北,南,西,东)的代理人制定一个继承状态公理。网格在1,1和2,2处有两个障碍物,并且代理的初始位置是3,3。代理人应该到达位于1,2的传送门而不会碰到任何障碍物。这是代码:

obstacle(1,1).
obstacle(2,3).
teleportal(1,3).
agent(3,3,s0).
agent(X, Y, result(A,S)):-
   (  agent(X,Y,S), 
      (  A = north, (X=0; (obstacle(X2,Y), X2 is X-1)))
      ;
        (A = south, (X=3; (obstacle(X2,Y), X2 is X+1)));
        (A = west, (Y=0; (obstacle(X,Y2), Y2 is Y-1)));
        (A = east, (Y=3; (obstacle(X,Y2), Y2 is Y+1)))) 
        ;
        (agent(X2, Y, S), A = north, X > 0, X2 is X-1);
        (agent(X2, Y, S), A = south, X < 3, X2 is X+1);
        (agent(X, Y2, S), A = west, Y > 0, Y2 is Y-1);
        (agent(X, Y2, S), A = east, Y < 3, Y2 is Y+1).

escaped(S):- agent(X,Y,S), teleportal(X,Y).

当我运行escape(S)时,它会出现以下错误:超出本地堆栈

0 个答案:

没有答案