我有解决猴子和香蕉问题的prolog代码,但我的编译器发出错误
这是我的代码:
move(state(middle, onbox, middle, hasnot), grasp,
state(middle, onbox, middle, has)).
move(state(Pos, onfloor, Pos, Has), climb,
state(Pos, onbox, Pos, Has)).
move(state(Pos1, onfloor, Pos1, Has), push(Pos1, Pos2),
state(Pos2, onfloor, Pos2, Has)).
move(state(Pos1, onfloor, Box, Has), walk(Pos1, Pos2),
state(Pos2, onfloor, Box, Has)).
canget(state(_,_,_,has)).
canget(State1) :- move(State1, Move, State2), canget(State2).
错误:Move是Singleton Variable 我错了什么?
答案 0 :(得分:1)
canget(S0) :-
S = state(_,_,_,has),
closure0(\X^Y^move(X,_,Y),S0,S).