1

I am trying to use this Planner https://www.cs.unm.edu/~luger/ai-final/code/PROLOG.planner.html .

I want to search a space with a numerical value. Below you can see my implementation of sum that is tested and seems to work. Then there are my two moves, plus and minus, where I delete the value(X) and add value(Y) where Y is X +- 1 respectively.

If I now consult the planner (last statement with go), I do not get the expected result of plus() but instead false as the planner does not find a way from value(2) to value(3).

sum(X,Y,Z) :- Z is X+Y.

move(plus(), [value(X)], [del(value(X)), sum(X,1,Y) , add(value(Y))]).
move(minus(), [value(X)], [del(value(X)), sum(X,-1,Y) , add(value(Y))]).

go([value(2)], [value(3)]).
false
  • 10,264
  • 13
  • 101
  • 209
panwauu
  • 47
  • 5

1 Answers1

0

The predicate move(Action, Preconditions, Effects) describes the changes caused by the execution of Action in a state where the conditions established in list Preconditions hold. In a fact for this predicate, the list Effects must consist only of terms of the form add(Fluent) and del(Fluent). So, I think the correct definition of actions plus and minus should be as follows:

move(plus,  [value(X)], [del(value(X)), add(value(Y))]) :- Y is X + 1.
move(minus, [value(X)], [del(value(X)), add(value(Y))]) :- Y is X - 1.
slago
  • 5,025
  • 2
  • 10
  • 23