C463/B551 Artificial Intelligence
Homework 10
Due date: Tuesday, April 15, 2008.
Original
project as reference
Ex. 1 This project implements a version of PacMan in
Python. We'll implement a fuzzy logic controller for the PacMan.
Download the zip file from the link above and unzip it. Read the
instructions on how to run the script with different layouts and
different agents. In the same folder, download the following file:
fuzzyAgents.py
For example, to run the random agent from the file we're adding to
the project on the tinyMaze layout we would use the command:
python pacman.py -l tinyMaze -p RandomAgent
To integrate our controller with the project, we need to define
our own special agent called FuzzyAgent found in fuzzyAgents.py. Every
agent needs to define the function getAction that returns the next
step to be taken by the Pacman.
What you need to know (and you may use other ways to get the same
information if you find them easier):
- The state parameter in the function
getAction is of the class GameState defined in pacman.py.
- The state allows you to find all the directions in which the
pacman can move:
state.getLegalPacmanActions()
- To find the food information you need to call
state.getFood()
which returns a 2D list of Booleans. A similar function getWalls gives
you information about the walls.
- The function calls state.getCapsules() and state.getGhostStates()
give you the remaining capsules and the positions of the ghosts as
lists of coordinates.
- The function call state.getPacmanPosition() returns the
current coordinates of the pacman in that state.
- You can generate a state resulting from executing a move from the
current state with:
state.generateSuccessor(0, action)
where action would be one of the possible directions that you get from
the function above.
Fuzzy Agent To implement the fuzzy controller, you'll have
to implement the following functions:
- fuzzify(action): This function should return a fuzzy value
of attraction towards the direction given by the action parameter. In
this function you must consider both the possible food or capsules in
that direction and the danger from ghosts.
- defuzzify(self, actions, values): This function should
choose one of the possible actions based on their fuzzy values as an
index in the array of actions. You can use the past action and its
value in the decision if you want. The easiest way to choose is to
select the action with the maximum corresponding value.
Turn in: the file fuzzyAgents.py and any other file that you
modify or add.
Extra credit: The agent with the best score will get 5 extra
credit points, the second place 3 points, and the third place 1
point. There is a "shoot for the moon" option of aiming for the lowest
possible score, and the winner in this category gets 3 points. You can
submit two versions of the agent if you want, one for a high score and
one for a low score.