Artificial Intelligence
Homework 5 |
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
In the distant past, Pac-Men did not flee from ghosts. They hunted ghosts using only their ears. In this assignment, you will restore Pac-Man to his ghost-hunting origins using exact and approximate inference algorithms for tracking. This is a programming assignment and you may work with a partner if you choose. Click here to download the starter code. You will notice that the code is arranged in packages:
Ghost HuntingPac-Man and the ghost live on a 10x10 grid world and can only move in cardinal directions: up, down, left, and right. At each time step, a ghost chooses between staying where it is or moving to 1 of its cardinal neighbors. Depending upon the ghost's location, it may have 2, 3, or 4 neighbors. Pac-Man uses his ears (sonar) to obtain a noisy estimate of the Manhattan distance between him and the ghost. Unfortunately, his ears are not perfect and Pac-Man does not know the true Manhattan distance. He has only his noisy estimate to use when tracking the ghost. Pac-Man maintains a distribution over where he believes the ghost is located. The darker green cells indicate a higher level of belief and the lighter green cells indicate a lower level of belief. Dynamic Bayesian NetworkThe image below shows the dynamic Bayesian Network that we will be using to model this domain.
Using Inference to Track The GhostPacman.java is an abstract class that contains the abstract method: Pac-Man's belief distribution is stored in an instance variable in Pacman.java. Your update() method should store the updated belief distribution in this instance variable. My move() method then takes this updated belief distribution and chooses a direction for Pacman to move. In PacmanForwardAlgorithm, the update() method should use The Forward Algorithm to compute: In PacmanParticleFilter, the update() method should use a particle filter to estimate the same distribution. Again, the pseudocode for this algorithm is posted on the course webpage. Both of these algorithms require you to compute p(NDt | Gt). You will need to derive this quantity given the dynamic Bayesian network and the distributions defined above (using the inference by enumeration algorithm we discussed in class). Note that your update() method performs only a single iteration of The Forward Algorithm or the Particle Filtering algorithm. It is my code (in GhostBustersPanel) that will call update() at each time step to get the updated belief distribution. Thus, the constructor should perform the initialization step (using the prior distribution), and the update() method should then take that belief distribution and update it given an observation of the noisy distance of the ghost.
Debugging Your CodeI highly recommend breaking your code into small methods so that you can test each method. I have done this for you inside the PacmanParticleFilter class. I also highly recommend computing the Forward Algorithm values by hand on a sheet of paper to check your code against. If you do this, you should change the grid size to something more manageable like 3x3. (You can change the size of the grid inside of GhostBustersPanel.) Here is the emission distribution for a 3x3 grid:
Initially, the ghost has an equal probability of being in any of the cells -- i.e., p(G0) is a uniform distribution over the cells. Running Your CodeThe main() method is in the GhostBusters class. This class does not take any command line arguments. Grading and SubmissionYour assignment will be graded based upon correctness, efficiency (i.e. the time/space complexity of your implementation), as well as its adherence to the Java style guide. AcknowledgementsThis assignment was taken and adapted from the Pacman Projects. |