| Neil York Oliver 2004-05-04, 2:59 pm |
| Hi,
I am having a problem with this procedure and would appreciate your help.
select_action (CurrentLocation,Intentions,ActionSelect
ed)
Current location will be a singleton list containing one actom of the
Agent's location. at(X,Y)
Then, the Intentions is a list of item (each item is represented as
item(X,Y,S). X and Y denotes the location (grid) of the item and S is the
value of item.)
What I want as an output here is an ActionSelected.
There are three types of action the agent can execute in any one cycle:
a.. null - the agent does nothing
b.. takes(X,Y) - the agent takes the item at (X,Y) and gains the
associated score (S)
c.. move(X,Y) - the agent moves to the location (X,Y)
The item selected by the agent will be the first on the list of Intentions.
If it is "move" action, the action should also specify the coordinates to
which the agent should move (one square from the current location
(CurrentLocation -at(X,Y))
Assume that there is no obstacles in the path so any path is fine towards
the item (the path that agent takes towards the item does not matter). I
will be using Manhattan distance as below
% Manhattan distance between two squares
distance((X,Y), (X1,Y1), D) :-
dif(X, X1, Dx),
dif(Y, Y1, Dy),
D is Dx + Dy.
% D is |A - B|
dif(A, B, D) :-
D is A - B, D >= 0, !.
dif(A, B, D) :-
D is B - A.
Please help me with the simplest algorithms to implement this problem. How
can I implement recursion in prolog in this context?
Thanks.
Love,
Neil
|