Enough of defense,
Onto enemy terrain.
Capture all their food!
The course contest involves a multi-player capture-the-flag variant of Pacman, where agents control both Pacman and ghosts in coordinated team-based strategies. Your team will try to eat the food on the far side of the map, while defending the food on your home side. The contest code is available as a zip archive.
Key files to read: | |
capture.py |
The main file that runs games locally. This file also describes the new capture the flag GameState type and rules. |
captureAgents.py |
Specification and helper methods for capture agents. |
baselineTeam.py |
Example code that defines two very basic reflex agents, to help you get started. |
myTeam.py |
This is where you define your own agents for inclusion in the nightly tournament. (This is the only file that you submit.) |
Supporting files (do not modify): | |
---|---|
game.py |
The logic behind how the Pacman world works. This file describes several supporting types like AgentState, Agent, Direction, and Grid. |
util.py |
Useful data structures for implementing search algorithms. |
distanceCalculator.py |
Computes shortest paths between all maze positions. |
graphicsDisplay.py |
Graphics for Pacman |
graphicsUtils.py |
Support for Pacman graphics |
textDisplay.py |
ASCII graphics for Pacman |
keyboardAgents.py |
Keyboard interfaces to control Pacman |
layout.py |
Code for reading layout files and storing their contents |
Academic Dishonesty: While we won't grade contests, we still expect you not to falsely represent your work. Please don't let us down.
Scoring: When a Pacman eats a food dot, the food is permanently removed and one point is scored for that Pacman's team. Red team scores are positive, while Blue team scores are negative.
Eating Pacman: When a Pacman is eaten by an opposing ghost, the Pacman returns to its starting position (as a ghost). No points are awarded for eating an opponent.
Power capsules: If Pacman eats a power capsule, agents on the opposing team become "scared" for the next 40 moves, or until they are eaten and respawn, whichever comes sooner. Agents that are "scared" are susceptible while in the form of ghosts (i.e. while on their own team's side) to being eaten by Pacman. Specifically, if Pacman collides with a "scared" ghost, Pacman is unaffected and the ghost respawns at its starting position (no longer in the "scared" state).
Observations: Agents can only observe an opponent's configuration (position and direction) if they or their teammate is within 5 squares (Manhattan distance). In addition, an agent always gets a noisy distance reading for each agent on the board, which can be used to approximately locate unobserved opponents.
Winning: A game ends when one team eats all but two of the opponents' dots. Games are also limited to 1200 agent moves (300 moves per each of the four agents). If this move limit is reached, whichever team has eaten the most food wins. If the score is zero (i.e., tied) this is recorded as a tie game.
Computation Time: We will run your submissions on an Amazon EC2 small instance, which has a 1.2 Ghz Xeon / Opteron processor equivalent and 1.7gb of RAM. Each agent has 1 second to return each action. Each move which does not return within one second will incur a warning. After three warnings, or any single move taking more than 3 seconds, the game is forfeit. There will be an initial start-up allowance of 15 seconds (use the registerInitialState
function). If you agent times out or otherwise throws an exception, an error message will be present in the log files, which you can download from the results page (see below).
You'll form teams and upload bots on the new cs188.org website. Your team must defined in
the myTeam.py
file, which you'll upload to enter
the contest. Modifications to other provided files are not possible.
Once your bot is uploaded to the contest web page, you'll be able to play against any other bots, including the staff bots, and any other players will be able to play against yours. The system may also start random games spontaneously to more accurately determine your rating.
baselineTeam
that the staff has provided:
python capture.py
A wealth of options are available to you:
python capture.py --helpThere are four slots for agents, where agents 0 and 2 are always on the red team, and 1 and 3 are on the blue team. Agents are created by agent factories (one for Red, one for Blue). See the section on designing agents for a description of the agents invoked above. The only team that we provide is the
baselineTeam
. It is chosen by default as both the red and blue team, but as an example of how to choose teams:
python capture.py -r baselineTeam -b baselineTeamwhich specifies that the red team
-r
and the blue team -b
are both created from baselineTeam.py
.
To control one of the four agents with the keyboard, pass the appropriate option:
python capture.py --keys0The arrow keys control your character, which will change from ghost to Pacman when crossing the center line.
defaultcapture
layout. To test your agent on other layouts, use the -l
option.
In particular, you can generate random layouts by specifying RANDOM[seed]
. For example, -l RANDOM13
will use a map randomly generated with seed 13.
Baseline Team: To kickstart your agent design, we have provided you with a team of two baseline agents, defined in baselineTeam.py
. They are both quite bad. The OffensiveReflexAgent
moves toward the closest food on the opposing side. The DefensiveReflexAgent
wanders around on its own side and tries to chase down invaders it happens to see.
Interface: The GameState
in capture.py
should look familiar, but contains new methods like getRedFood
, which gets a grid of food on the red side (note that the grid is the size of the board, but is only true for cells on the red side with food). Also, note that you can list a team's indices with getRedTeamIndices
, or test membership with isOnRedTeam
.
Finally, you can access the list of noisy distance observations via getAgentDistances
. These distances are within 6 of the truth, and the noise is chosen uniformly at random from the range [-6, 6] (e.g., if the true distance is 6, then each of {0, 1, ..., 12} is chosen with probability 1/13). You can get the likelihood of a noisy reading using getDistanceProb
.
Distance Calculation: To facilitate agent development, we provide code in distanceCalculator.py
to supply shortest path maze distances.
To get started designing your own agent, we recommend subclassing the CaptureAgent
class. This provides access to several convenience methods. Some useful methods are:
def getFood(self, gameState): """ Returns the food you're meant to eat. This is in the form of a matrix where m[x][y]=true if there is food you can eat (based on your team) in that square. """ def getFoodYouAreDefending(self, gameState): """ Returns the food you're meant to protect (i.e., that your opponent is supposed to eat). This is in the form of a matrix where m[x][y]=true if there is food at (x,y) that your opponent can eat. """ def getOpponents(self, gameState): """ Returns agent indices of your opponents. This is the list of the numbers of the agents (e.g., red might be "1,3,5") """ def getTeam(self, gameState): """ Returns agent indices of your team. This is the list of the numbers of the agents (e.g., red might be "1,3,5") """ def getScore(self, gameState): """ Returns how much you are beating the other team by in the form of a number that is the difference between your score and the opponents score. This number is negative if you're losing. """ def getMazeDistance(self, pos1, pos2): """ Returns the distance between two points; These are calculated using the provided distancer object. If distancer.getMazeDistances() has been called, then maze distances are available. Otherwise, this just returns Manhattan distance. """ def getPreviousObservation(self): """ Returns the GameState object corresponding to the last state this agent saw (the observed state of the game last time this agent moved - this may not include all of your opponent's agent locations exactly). """ def getCurrentObservation(self): """ Returns the GameState object corresponding this agent's current observation (the observed state of the game - this may not include all of your opponent's agent locations exactly). """ def debugDraw(self, cells, color, clear=False): """ Draws a colored box on each of the cells you specify. If clear is True, will clear all old drawings before drawing on the specified cells. This is useful for debugging the locations that your code works with. color: list of RGB values between 0 and 1 (i.e. [1,0,0] for red) cells: list of game positions to draw on (i.e. [(20,5), (3,22)]) """
Restrictions: You are free to design any agent you want. However, you will need to respect the provided APIs if you want to participate in the tournaments. Agents which compute during the opponent's turn will be disqualified. In particular, any form of multi-threading is disallowed, because we have found it very hard to ensure that no computation takes place on the opponent's turn.
Warning: If one of your agents produces any stderr output, that output may be included in the contest results posted on the website. Additionally, in some cases a stack trace may be shown among this output in the event that one of your agents throws an exception. You should design your code in such a way that this does not expose any information that you wish to keep confidential.
Teams: You may work in teams of up to 4 people.
Prizes: Rankings are determined according to a rating system based on the standard Elo system used first in chess and adopted by many other games. Your rating will adjust as you play games, and the system may make additional adjustments as more information becomes available.
In addition to bot ratings, a team rating is available which averages over recently submitted bots. It is purely informational and may help you keep track of where you stand when submitting new bots, but does not affect your rank. If your bot has played fewer than 10 matches, its rating will be shown in parentheses to note its provisional nature.
Extra credit points on the final will be awarded based on bot ranking. Based on ranking at the end of April 18, the top 10 teams will receive 0.5 points of extra credit, the top five 1 point, the top three 1.5 points, and the number one team 2 points. At the end of the contest on April 25, the top 10 teams will receive 1 point of extra credit, the top five 2 points, the top three 3 points, and the number one team 4 points.
Additionally, any bot which achieves a win record of better than 50% against every staff bot (playing at least 10 games each) at the end of the contest will receive one additional point of extra credit.
You are encouraged to start early to ensure your place in the first round of extra credit and establish your record against the staff agents.
Important dates:
Sunday | 4/8/2012 | Contest announced and posted |
Wednesday | 4/18/2012 | First round of extra credit awarded |
Wednesday | 4/25/2012 | Final round of extra credit awarded |
Thursday | 4/26/2012 | Results announced in class |
Have fun! Please bring our attention to any problems you discover.