You are requested to deliver a tar.gz archive containing:
- Your report named
report.pdf
.- Your report must be at most 5 pages long.
- Fill in the following template to write your report.
- In French or English.
- A file named
bayesfilter.py
containing your implementation of the Bayes filter algorithm.- Simply modify the provided
bayesfilter.py
file. ⚠️ Do not change the class name (BeliefStateAgent
).
- Simply modify the provided
- (optional) A file named
pacmanagent.py
containing your implementation of the BONUS.- Simply modify the provided
pacmanagent.py
file. :warning: A penalty of -2 points on the final grade will be applied if the files are not named based on the instructions above.
- Simply modify the provided
This part is due by November 25, 2021 at 23:59. This is a hard deadline.
In this third part of the project, Pacman got tired of ghosts wandering around him. So he decided to buy a laser gun and kill them. But while he shot them, he figured out that the gun has instead turned them into invisible but edible ghosts! Fortunately, as it was part of a box that he bought from a flea market, he also got his hands on a rusty sensor, which still works but is subject to measurement errors which are described in the user manual.
A lot of confusion arose since Pacman shot the ghosts: he has no idea where they currently are in the maze! However, he knows that the ghosts are confused and should be willing to escape from him.
More precisely, he knows that the first ghost, named scared
, is more fearful than the second ghost, named afraid
, who is more fearful than the third ghost, named confused
.
Your task is to design an intelligent agent based on the Bayes filter algorithm (see Lecture 6) for locating all the ghosts in the maze.
You may use the following command line to start a game where the sole eadible scared
ghost wanders around the maze while Pacman, controlled by the humanagent.py
policy, tries to locate him with a (very) rusty sensor:
python run.py --agentfile humanagent.py --bsagentfile bayesfilter.py --ghostagent scared --nghosts 1 --seed -1 --layout large_filter
Note that when you use multiple ghosts, they all run the same policy (e.g., all scared
). Change the value of seed
- for random number generator - to a positive value to ease reproducibility of your experiments.
You are asked to answer the following questions:
-
Bayes filter
- 1.a. - 2 point - Describe mathematically the sensor model of the rusty sensor, as implemented in
_get_evidence
of theBeliefStateAgent
class. - 1.b. - 2 points - Provide a unified parametrized transition model from which the ghosts
scared
,afraid
andconfused
can be derived. Derive this model from the ghost implementations found in/pacman_module/ghostAgents.py
(functionsgetDistribution
). Your model should specify a single free parameter. :warning: Be aware that in project 2, the ghosts are now able to go move backward, on the contrary to project 1.
Answers to the previous questions should not make any reference to the API nor include pseudo-code.
- 1.a. - 2 point - Describe mathematically the sensor model of the rusty sensor, as implemented in
-
Implementation
- 2.a. - 6 points - Implement the Bayes filter algorithm to compute Pacman's belief state. This should be done in the
_get_updated_belief
function ofbayesfilter.py
.- Your function
_get_updated_belief
(2 points) should use the functions_get_sensor_model
(2 points) and_get_transition_model
(2 points) that you should also define yourself. - Your implementation must work with multiple ghosts (all running the same policy).
- Pacman's belief state should eventually converge to an uncertainty area for each ghost.
- Your filter should consider the Pacman position, as Pacman may wander freely in the maze.
- Your function
- 2.a. - 6 points - Implement the Bayes filter algorithm to compute Pacman's belief state. This should be done in the
-
Experiment
- 3.a. - 1 point - Provide a measure which summarizes Pacman's belief state (i.e., its uncertainty).
- 3.b. - 1 point - Provide a measure of the quality of the belief state(s). You may assume access to the ground truth (i.e., the true position of the ghost(s)).
- 3.c. - 3 points - Run your filter implementation on the
/pacman_module/layouts/large_filter.lay
and the/pacman_module/layouts/large_filter_walls.lay
layouts, against each type of ghost. Report your results graphically.- Record your measures (see
_record_metrics
function inbayesfilter.py
) averaged over several trials. - Your results should come with error bars.
- The number of trials must be high enough and their duration long enough so that the measures have converged.
- Record your measures (see
- 3.d. - 1 points - Discuss the effect of the ghost transition model parameter on its own behavior and on Pacman's belief state. Consider the two provided layouts. Motivate your answer by using your measures and the model itself. Use the default sensor variance.
- 3.e. - 1 points - Discuss the effect of the sensor variance (as set through the
--sensorvariance
command line argument) on Pacman's belief state. - 3.f. - 1 points - How would you implement a Pacman controller to eat ghosts using only its current position, the set of legal actions and its current belief state?
- 3.g. - BONUS 3 points - Implement this controller in the
pacmanagent.py
file.
Besides the questions you're expected to answer, you will also be evaluated according to the following criteria:
- Code style - 2 points
- PEP8 compatibility - 0.8 point - PEP8 guidelines are provided at Style Guide for Python Code. A script will be executed to check the compatibility of your code.
- 0.8 point : the script runs without error.
- 0 point: any error during the execution of the script.
- Specification - 1.2 point - correctness of the specification of your functions.
- 1.2 point : all specifications are correct.
- 0.9 point : at least 75% correct specifications.
- 0.6 point : at least 50% correct specifications.
- 0.3 point : at least 25% correct specifications.
- 0 point : less than 25% correct specifications.
- PEP8 compatibility - 0.8 point - PEP8 guidelines are provided at Style Guide for Python Code. A script will be executed to check the compatibility of your code.
Note that your implementation might be tested on other layouts, with Pacman moving arbitrarily.
- Any modification of the template: - 2 points
- Only the first 5 pages of the report will be taken into account for the evaluation.
The programming projects are adapted from CS188 (UC Berkeley).