For Programmers: Free Programming Magazines  


Home > Archive > Prolog > April 2004 > need help for this procedure









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author need help for this procedure
Neil York Oliver

2004-04-29, 7:58 am


Hi,

Here is the detailed description in plain text..

procedure select_action(CurrentLocation, [Goal|Intentions], Action) - which
takes the agent's current location (a singleton list containing a term
at(X,Y)) and the list of intentions, and computes an action to be taken by
the agent. The goal selected by the agent is the first on the list of
intentions, and in the case of a move action, the action should specify the
coordinates to which the agent should move (being one square from the agent'
s current location). Due to the use of Manhattan distance and the fact that
there are no obstacles in the world, the exact path the agent takes towards
the goal does not matter much, so choose the simplest way of
implementing this procedure. //ITEM =GOAL...use goal here

The case is two-dimensional grid of locations, extending to infinity in both
directions.Some locations contain "item" (of varying values), which agents
must "takes"
in order to score points. An agent takes a piece of item by moving to its
location and executing antake action. Agents can move one square at a time
either horizontally or vertically. Item may spontaneously appear at a
randomly determined location at any time(0.3 probabilty).The initial
location of the agent is represented by the list [at(0,0)].

The agent's goals at any time are a list of locations of items and their
values. Each goal of he agent is represented as an term goal(X,Y,S), where
(X,Y) is the location of the item and S isits value. The agent's intentions
are these goals ordered according to some priority. To fulfil an intention,
the agent's action is just to move along some path towards the corresponding
item and gain score(S value) (the actual path is determined at run time).
There are three types of action the agent can execute in any one cycle:
null - the agent does nothing
take(X,Y) - the agent takes the item at (X,Y) and gains the score
move(X,Y) - the agent moves to the location (X,Y)

The agent then selects an action for execution from the current list of
intentions (here the agent always selects the first intention on the list if
there is one, and chooses an appropriate action depending on its current
position - either taking the item or moving closer to the item).

The agent's prioritization strategy is very simple: each new goal is
inserted into the list of intentions in order of the closeness of the item
to the agent's current position (closer items coming earlier in the list).
However, once a goal is incorporated into the list of intentions, it is
never re-prioritized with respect to existing goals as the agent moves about
(hence after some time the list may not accurately reflect the closeness of
food to the agent). This strategy thus
incorporates some "commitment" of the agent to pursuing this goal (the agent
only changes itsintention to eat a particular item if another food item
closer to the agent appears). The agent's simple selection strategy of
choosing the first intention on the list means that the agent choosed to go
towards the item nearest to the agent when it appeared.

How could I implement this using lists in prolog?


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com