-
Notifications
You must be signed in to change notification settings - Fork 0
/
contest.html
248 lines (170 loc) · 12.3 KB
/
contest.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Contest: Pacman Capture the Flag</title>
<style type="text/css">
<!--
.style1 { font-style: italic; font-weight: bold }
-->
</style>
<link href="projects.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style2 { color: #990000 }
-->
</style>
</head>
<body>
<h2>Contest: Pacman Capture the Flag</h2>
<blockquote>
<center>
<img src="capture_the_flag.png" width="540" height="210">
</center>
<p><cite><center>Enough of defense,<br>
Onto enemy terrain.<br>
Capture all their food!</center></cite></p>
</blockquote>
<h3>Introduction</h3>
<p>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 <a href="contest.zip">zip archive</a>.
<table border="0" cellpadding="10">
<tr><td><b>Key files to read:</b></td></tr>
<tr><td><code>capture.py</code> </td>
<td>The main file that runs games locally. This file also describes the new capture the flag GameState type and rules.</td></tr>
<!--
<tr><td><code>pacclient.py</code> </td>
<td>The main file that runs games over the network. </td></tr>-->
<tr><td><code>captureAgents.py</code> </td>
<td>Specification and helper methods for capture agents. </td></tr>
<tr><td><code>baselineTeam.py</code> </td>
<td>Example code that defines two very basic reflex agents, to help you get started.</td></tr>
<tr><td><code>myTeam.py</code> </td>
<td>This is where you define your own agents for inclusion in the nightly tournament. (This is the only file that you submit.)</td></tr>
<tr><th colspan="2" align="left"><b>Supporting files (do not modify):</b></th></tr>
<tr><td><code>game.py</code></td>
<td>The logic behind how the Pacman world works. This file describes several supporting types like AgentState, Agent, Direction, and Grid.</td></tr>
<tr><td><code>util.py</code></td>
<td>Useful data structures for implementing search algorithms.</td></tr>
<tr><td><code>distanceCalculator.py</code> </td>
<td>Computes shortest paths between all maze positions. </td></tr>
<tr><td><code>graphicsDisplay.py</code></td>
<td>Graphics for Pacman</td></tr>
<tr><td><code>graphicsUtils.py</code></td>
<td>Support for Pacman graphics</td></tr>
<tr><td><code>textDisplay.py</code></td>
<td>ASCII graphics for Pacman</td></tr>
<tr><td><code>keyboardAgents.py</code></td>
<td>Keyboard interfaces to control Pacman</td></tr>
<!-- <tr><td><code>pygameDisplay.py</code></td>
<td>New faster graphics for Pacman (in development)</td></tr>
<tr><td><code>pygameAgents.py</code></td>
<td>Keyboard agents for the pygame graphics package</td></tr>
-->
<tr><td><code>layout.py</code></td>
<td>Code for reading layout files and storing their contents</td></tr>
</table>
<p><strong>Academic Dishonesty:</strong> You might be tempted to copy someone else's code. Don't! This is a modified version of the game, so others' code might not work. Plus, we will be conducting code checks; if you misrepresent your work, you will be disqualified (0 points!).
<h3>Rules of Pacman Capture the Flag</h3>
<b>Layout:</b> The Pacman map is now divided into two halves: blue (right) and red (left). Red agents (which all have even indices) must defend the red food while trying to eat the blue food. When on the red side, a red agent is a ghost. When crossing into enemy territory, the agent becomes a Pacman.
<p><b>Scoring:</b> When a Pacman eats a food dot, the food is removed, when Pacman reaches its base, one point is added to its team's score. Red team scores are positive, while Blue team scores are negative.
<p><b>Eating Pacman:</b> 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.
<p><b>Power capsules:</b> 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).
<p><b>Observations:</b> Agents can always observe an opponent's configuration (position and direction) if they or their teammate is within 5 squares (Manhattan distance).
<p><b>Winning:</b> 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.
<p><b>Computation Time:</b> 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 <code>registerInitialState</code> 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).
<h3>Getting Started</h3>
By default, you can run a game with the simple <code>baselineTeam</code> that the staff has provided:
<pre>python capture.py</pre>
<p>A wealth of options are available to you:
<pre>python capture.py --help</pre>
There 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 <code>baselineTeam</code>. It is chosen by default as both the red and blue team, but as an example of how to choose teams:
<pre>python capture.py -r baselineTeam -b baselineTeam</pre>
which specifies that the red team <code>-r</code> and the blue team <code>-b</code> are both created from <code>baselineTeam.py</code>.
To control one of the four agents with the keyboard, pass the appropriate option:
<pre>python capture.py --keys0</pre>
The arrow keys control your character, which will change from ghost to Pacman when crossing the center line.
<h4>Layouts</h4>
By default, all games are run on the <code>defaultcapture</code> layout. To test your agent on other layouts, use the <code>-l</code> option.
In particular, you can generate random layouts by specifying <code>RANDOM[seed]</code>. For example, <code>-l RANDOM13</code> will use a map randomly generated with seed 13.
<h3>Game Types</h3>
You can play the game in two ways: local games, and nightly tournaments.
<p>Local games (described above) allow you to test your agents against the baseline teams we provide and are intended for use in development.
<h3>Designing Agents</h3>
Unlike project 2, an agent now has the more complex job of trading off offense versus defense and effectively functioning as both a ghost and a Pacman in a team setting. Furthermore, the limited information provided to your agent and the time limit of computation introduce new challenges.
<p><b>Baseline Team:</b> To kickstart your agent design, we have provided you with a team of two baseline agents, defined in <code>baselineTeam.py</code>. They are both quite bad. The <code>OffensiveReflexAgent</code> moves toward the closest food on the opposing side. The <code>DefensiveReflexAgent</code> wanders around on its own side and tries to chase down invaders it happens to see.
<p><b>File naming:</b> For the purpose of testing or running games locally, you can define a team of agents in any arbitrarily-named python file. When submitting to the nightly tournament, however, you must define your agents in <code>myTeam.py</code> (and you must also create a <code>name.txt</code> file that specifies your team name).
<p><b>Interface:</b> The <code>GameState</code> in <code>capture.py</code> should look familiar, but contains new methods like <code>getRedFood</code>, 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 <code>getRedTeamIndices</code>, or test membership with <code>isOnRedTeam</code>.
<p><b>Distance Calculation: </b>To facilitate agent development, we provide code in <code>distanceCalculator.py</code> to supply shortest path maze distances.
<p>To get started designing your own agent, we recommend subclassing the <code>CaptureAgent</code> class. This provides access to several convenience methods. Some useful methods are:
<pre>
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)])
"""
</pre>
<p><b>Restrictions:</b> You are free to design any agent you want. However, you will need to respect the provided APIs. 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.
<!--Because the tournament will be run using the online architecture, you can run your agent from your machine using any resources or code you want; you can even write code in different programming languages if you so desire. Change pacclient.py at your own risk, though, because you don't want to break the network functionality. //-->
<p>
<img src="capture_the_flag2.png" width="785" height="444" />
<p> Have fun! Please bring our attention to any problems you discover.
</body>
</html>