I got stuck with a small prolog predicate and needs help to solove this.
The description is
getIntentions1(Options, Beliefs, Intentions, Intentions1) which has four arguments: a list of options each of the form goal(X,Y,S), a list of beliefs (here containing one term of the form at(X,Y)), the current list of intentions each of the form goal(X,Y,S), and computes a list which contains the new options inserted into the current list of intentions in order of the Manhattan distance of the goal from the agent's current location. If an option is the same distance from the agent as an existing goal, the new goal should be placed later in the list.
HERE, I have my program and it does not produce the expected output. I need help to fix this. See the attached file "[url removed, login to view]" for the code and details. The code for calculating Manhantan distance is working fine and don't need a change.
1) Complete working source code - only one predicate "getIntentions1" (probably helper predicates as well).
2) Explanation pointing out to my errors.