CSE 537 Project 6: Ghostbusters!
(100 points, Due Mon Dec 16 before midnight)

GHOSTBUSTERS

Introduction

Pac-Man has been running from ghosts all his life, but things were not always so. Legend has it that many years ago, Pac-Man's grandfather Grandpac learned to hunt ghosts for sport. However, he was blinded by his power and could subsequently only track ghosts by their banging and clanging sounds.

In this project, you will design Pac-Man agents that use sensors to locate invisible ghosts.

The code for this project contains the following files, available as a zip archive.

Files you will edit
bustersAgents.py Agents for playing the Ghostbusters variant of Pac-Man.
inference.py Code for tracking ghosts over time using their sounds.
Files you will not edit
busters.py The main entry to Ghostbusters (replacing pacman.py)
bustersGhostAgents.py New ghost agents for Ghostbusters
distanceCalculator.py Computes maze distances
game.py Inner workings and helper classes for Pac-Man
ghostAgents.py Agents to control ghosts
graphicsDisplay.py Graphics for Pac-Man
graphicsUtils.py Support for Pac-Man graphics
keyboardAgents.py Keyboard interfaces to control Pac-Man
layout.py Code for reading layout files and storing their contents
util.py Utility functions

What to submit: You will fill in portions of bustersAgents.py and inference.py during the assignment. You should submit these two files containing your code through BlackBoard. Please do not change the other files in this distribution or submit any of our original files other than inference.py and bustersAgents.py.

Evaluation: Your code will be autograded for technical correctness. Please do not change the names of any provided functions or classes within the code, or you will wreak havoc on the autograder. However, the correctness of your implementation -- not the autograder's judgements -- will be the final judge of your score. If necessary, we will review and grade assignments individually to ensure that you receive due credit for your work.

Ghostbusters and Probabilistic Inference

Your goal will be to program Pac-Man agents to hunt down scared but invisible ghosts. Pac-Man, ever resourceful, is equipped with sonar (ears) that provides noisy readings of the Manhattan distance to each ghost. The game ends when pacman has eaten all the ghosts.

To start, try playing a game yourself using the keyboard (preferably while listening to the pop classic Ghostbusters).

  python busters.py

The blocks of color indicate where each ghost could possibly be, given the noisy distance readings provided to Pac-Man. The noisy distances at the bottom of the display are always non-negative, and always within 7 of the true distance. The probability of a distance reading decreases exponentially with its difference from the true distance.

Your primary task in this project is to implement inference to track the ghosts. A crude form of inference is implemented for you by default: all squares in which a ghost could possibly be are shaded by the color of the ghost. Option -s shows where the ghost actually is.

  python busters.py -s -k 1

Naturally, we want a better estimate of the ghost's position. We will start by locating a single, stationary ghost using multiple noisy distance readings. The default BustersKeyboardAgent in bustersAgents.py uses the ExactInference module in inference.py to track ghosts.

Question 1 (50 points) Update the observe method in ExactInference class of inference.py to correctly update the agent's belief distribution over ghost positions. When complete, you should be able to accurately locate a ghost by circling it.

  python busters.py -s -k 1 -g StationaryGhost

Because the default RandomGhost ghost agents move independently of one another, you can track each one separately. The default BustersKeyboardAgent is set up to do this for you. Hence, you should be able to locate multiple stationary ghosts simultaneously. Encircling the ghosts should give you precise distributions over the ghosts' locations.

  python busters.py -s -g StationaryGhost

Note: Your busters agents have a separate inference module for each ghost they are tracking. That's why if you print an observation inside the observe function, you'll only see a single number even though there may be multiple ghosts on the board.

Hints:

Ghosts don't hold still forever. Fortunately, your agent has access to the action distribution for any GhostAgent. Your next task is to use the ghost's move distribution to update your agent's beliefs when time elapses.

Question 2 (50 points) Fill in the elapseTime method in ExactInference to correctly update the agent's belief distribution over the ghost's position when the ghost moves. When complete, you should be able to accurately locate moving ghosts, but some uncertainty will always remain about a ghost's position as it moves.

  python busters.py -s -k 1
  python busters.py -s -k 1 -g DirectionalGhost

Hints:

Now that Pac-Man can track ghosts, try playing without peeking at the ghost locations. Beliefs about each ghost will be overlaid on the screen. The game should be challenging, but not impossible.

  python busters.py -l bigHunt