Project 2: Multi-Agent Pacman
Due October 7, 2014, 2:30pmIntroductionIn this project, you will design agents for the classic version of Pacman, including ghosts. Along the way, you will implement both minimax and expectimax search and try your hand at evaluation function design. The code base has not changed much from the previous project, but please start with a fresh installation, rather than intermingling files from project 1. You can, however, use your The code for this project contains the following files. Key files to read
Files you can ignore
What to submit: You will fill in portions of 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 judgments -- 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. Academic Dishonesty: We will be checking your code against other submissions in the class for logical redundancy. If you copy someone else's code and submit it with minor changes, we will know. These cheat detectors are quite hard to fool, so please don't try. We trust you all to submit your own work only; please don't let us down. If you do, we will pursue the strongest consequences available to us. If you did not attend the first lecture and missed my overview over the academic dishonesty policy, it is your responsibility to inform yourself about it. Getting Help: You are not alone! If you find yourself stuck on something, contact the course staff for help. Office hours, section, and the newsgroup are there for your support; please use them. If you can't make our office hours, let us know and we will schedule more. We want these projects to be rewarding and instructional, not frustrating and demoralizing. But, we don't know when or how to help unless you ask. Piazza: Post your questions (but not project solutions) on the Class Piazza Page. Please be careful not to post spoilers to the newsgroup.
Multi-Agent PacmanFirst, play a game of classic Pacman: python pacman.pyNow, run the provided ReflexAgent in multiAgents.py :
python pacman.py -p ReflexAgentNote that it plays quite poorly even on simple layouts: python pacman.py -p ReflexAgent -l testClassicInspect its code (in multiAgents.py ) and make sure you understand what it's doing.
Question 1 (3 points) Improve the testClassic layout:
python pacman.py -p ReflexAgent -l testClassicTry out your reflex agent on the default mediumClassic layout with one ghost or two (and animation off to speed up the display):
python pacman.py --frameTime 0 -p ReflexAgent -k 1 python pacman.py --frameTime 0 -p ReflexAgent -k 2How does your agent fare? It will likely often die with 2 ghosts on the default board, unless your evaluation function is quite good. Note: you can never have more ghosts than the layout permits. Note: As features, try the reciprocal of important values (such as distance to food) rather than just the values themselves. Note: The evaluation function you're writing is evaluating state-action pairs; in later parts of the project, you'll be evaluating states. Options: Default ghosts are random; you can also play for fun with slightly smarter directional ghosts using Grading: we will run your agent on the python pacman.py -p ReflexAgent -l openClassic -n 10 -q Don't spend too much time on this question, though, as the meat of the project lies ahead. Question 2 (5 points) Now you will write an adversarial search agent in the provided Your code should also expand the game tree to an arbitrary depth. Score the leaves of your minimax tree with the supplied Important: A single search ply is considered to be one Pacman move and all the ghosts' responses, so depth 2 search will involve Pacman and each ghost moving two times. Grading: We will be checking your code to determine whether it explores the correct number of game states.
This is the only way reliable way to detect some very subtle bugs in implementations of minimax.
As a result, the autograder will be very
picky about how many times you call Hints and Observations
Question 3 (3 points) Make a new agent that uses alpha-beta pruning to more efficiently explore the minimax tree, in You should see a speed-up (perhaps depth 3 alpha-beta will run as fast as depth 2 minimax). Ideally, depth 3 on python pacman.py -p AlphaBetaAgent -a depth=3 -l smallClassic The Grading: Because we check your code to
determine whether it explores the correct number of states, it is important that you perform alpha-beta pruning without reordering children.
In other words, successor states should always be processed in the order returned by Question 4 (3 points)
Random ghosts are of course not optimal minimax agents, and so modeling them with minimax search may not be appropriate. Fill in You should now observe a more cavalier approach in close quarters with ghosts. In particular, if Pacman perceives that he could be trapped but might escape to grab a few more pieces of food, he'll at least try. Investigate the results of these two scenarios: python pacman.py -p AlphaBetaAgent -l trappedClassic -a depth=3 -q -n 10 python pacman.py -p ExpectimaxAgent -l trappedClassic -a depth=3 -q -n 10You should find that your ExpectimaxAgent wins about half the time, while your AlphaBetaAgent always loses. Make sure you understand why the behavior here differs from the minimax case.
Question 5 (6 points) Write a better evaluation function for pacman in the provided function
python pacman.py -l smallClassic -p ExpectimaxAgent -a evalFn=better -q -n 10 Document your evaluation function! We're very curious about what great ideas you have, so don't be shy. We reserve the right to reward bonus points for clever solutions and show demonstrations in class. Grading: we will run your agent on the
Hints and Observations
Mini Contest (3 points extra credit) Pacman's been doing well so far, but things are about to get a bit more challenging. This time, we'll pit Pacman against smarter foes in a trickier maze. In particular, the ghosts will actively chase Pacman instead of wandering around randomly, and the maze features more twists and dead-ends, but also extra pellets to give Pacman a fighting chance. You're free to have Pacman use any search procedure, search depth, and evaluation function you like. The only limit is that games can last a maximum of 3 minutes (with graphics off), so be sure to use your computation wisely. We'll run the contest with the following command:python pacman.py -l contestClassic -p ContestAgent -g DirectionalGhost -q -n 10 The three teams with the highest score (details: we run 10 games, games longer than 3 minutes get score 0, lowest and highest 2 scores discarded, the rest averaged) will receive 3, 2, and 1 extra credit points respectively and can look on with pride as their Pacman agents are shown off in class. Be sure to document what your agent is doing, as we may award additional extra credit to creative solutions even if they're not in the top 3. |