Review
- Due:
- 5:00am, Monday November 25, 2024
Description
There is a file in the assignment directory named wumpus.pl
. This is a
simulator for the Wumpus World. Your solution to this assignment can use the
following predicates:
initialize(Percecpt)
: Initialize a Wumpus World containing ThePercept
is a list of the form[Stench, Breeze, Glitter, Bump, Scream]
, with each element either yes or no. Currently, the world is initialized to the configuration in figure 7.2 in the textbook.restart(Percept)
: Restarts the Wumpus World that was last initialized usinginitialize(Percept)
. The same initial Percept is returned.agent_in_cave(X)
:X = yes
if the agent is in the cave.X = no
once the agent executes the climb action from square 1,1.agent_health(X)
:X = alive or dead
.agent_gold(N)
:N
= number of pieces of gold the agent is holding.agent_arrows(N)
:N
= number of arrows left to the agent.agent_score(N)
:N
is the agent’s score. The score starts at zero and is decremented by 1 for each action, decremented by 10,000 if dead, and incremented by 1,000 for each gold piece held by the agent after successfully climbing out of cave.execute(Action, Percept)
: Executes theAction
by updating information in the simulator and returns the appropriatePercept
. Possible actions aregoforward
,turnleft
,turnright
,grab
,shoot
, andclimb
.
Complete the Prolog file named run_trials.pl
by defining a predicate named
run_trials(Actions, Score, Iterations)
that initializes and repeatedly
restarts the Wumpus World, searching for a solution. A successful solution is
one where the agent leaves the cave with the gold piece. If a solution is
found, the Actions is bound to a list of actions, otherwise it is the empty
list. The Score is bound to the cumulative agent score The Iterations is bound
to the number of restarts.
The run_trials
should call the following agent predicates:
initialize_agent
: perform any agent initialization procedures before the trials begin.restart_agent
: perform any agent procedures needed between trials. For example, any clean-up or reinitialization.run_agent(Percept, Action)
: return an action given the current
There are some sample agents in the agents.pl
file that you can use for
testing purposes.
Here is an approximation to the algorithm that you should implement (using functions instead of predicates):
function Run-Trials out: Actions, Score, Iterations
initialize()
init_agent()
for i = 1 to max_agent_trials
percept := restart()
restart_agent()
Actions := empty list
for j = 1 to max_agent_actions
action := run_agent(percept)
append action to Actions
percept := execute(action)
if goal reached
Score := Score + agent_score()
return Actions, Score, i
if agent is dead or left cave
break
Score := Score + agent_score()
return empty list, Score, max_agent_trials
Turning in the Assignment
To submit your assignment, create a zip file named p5.zip
of a
DIRECTORY named p5
containing the following files:
run_trials.pl
Then submit that file to the appropriate folder on D2L.