manual.tex 30.2 KB
Newer Older
1 2
\documentclass[12pt]{article}

3 4 5 6 7 8 9 10 11 12
%% Allows itemranges in enumerations
\def\itemrange#1{%
\addtocounter{enumi}{1}%
\edef\labelenumi{\theenumi--\noexpand\theenumi}%
\addtocounter{enumi}{-1}%
\addtocounter{enumi}{#1}%
\item
\def\labelenumi{\theenumi}}
\renewcommand*{\labelenumi}{\theenumi}

13
\usepackage{hyperref,graphicx}
14
\usepackage[cm]{fullpage}
15
\usepackage{enumitem}
16
\usepackage{subcaption}
17

Matthew Hausknecht's avatar
Matthew Hausknecht committed
18
\title{RoboCup 2D Half Field Offense \\ Technical Manual}
19 20 21 22 23 24 25 26 27
\author{Matthew Hausknecht}

\begin{document}

\maketitle
\tableofcontents

\section{Overview}

Matthew Hausknecht's avatar
Matthew Hausknecht committed
28 29 30 31 32 33 34 35
This document describes the installation, usage, state, and action spaces of the HFO domain.

\section{Installation}

Installation with CMake:

\begin{verbatim}
  > mkdir build && cd build
36
  > cmake -DCMAKE_BUILD_TYPE=RelwithDebInfo ..
Matthew Hausknecht's avatar
Matthew Hausknecht committed
37 38 39 40 41 42
  > make -j4 # Replace 4 with the number of cores on your machine
  > make install # This just copies binaries to the HFO directory; no sudo required
\end{verbatim}

HFO installation has been tested on Ubuntu Linux and OSX. Successful
installation depends on
43
\verb+CMake, Boost-system, Boost-filesystem,+ and \verb+flex+.
Matthew Hausknecht's avatar
Matthew Hausknecht committed
44 45 46 47 48 49

These depedencies can be installed on Ubuntu using the following
command:\\
\verb+sudo apt-get install cmake libboost-filesystem libboost-system flex+

By default, the soccerwindow2 visualizer is also built and requires
Matthew Hausknecht's avatar
Matthew Hausknecht committed
50 51 52 53
\verb+Qt4+. Experimentally speaking, HFO is fully-functional without
the visualizer. To disable this component, use the following cmake
command:\\

54
\noindent \verb+  > cmake -DCMAKE_BUILD_TYPE=RelwithDebInfo -DBUILD_SOCCERWINDOW=False ..+
Matthew Hausknecht's avatar
Matthew Hausknecht committed
55 56 57 58 59 60 61 62 63 64 65 66 67 68

\subsection{Python Interface}

The Python interface is required for interfacing Python agents to the
HFO domain. To install this interface, from the main HFO directory:

\noindent \verb+  > pip install .+

or

\noindent \verb+  > pip install --user .+

if you have limited permissions on the machine.

69 70 71
Successful installation depends on
\verb+Python 2.7, 3.2, or above+ (tested with 2.7 and 3.5) and \verb+numpy+.

Matthew Hausknecht's avatar
Matthew Hausknecht committed
72 73 74 75 76 77 78 79 80 81 82 83 84 85
\section{Uninstall}

The install is completely contained in the HFO directory. Simply
delete this directory to uninstall. If you have installed the python
interface, uninstall it as follows: \verb+pip uninstall hfo+.

\begin{figure}[htp]
  \centering
  \includegraphics[width=\textwidth]{figures/HFODiagram}
  \caption{HFO is comprised of several components which communicate
    over the network. Network connections are depicted with orange
    ovals. Calling the HFO executable starts the trainer, visualizer,
    and all the offensive and defensive npcs (Agent2d) as well as the
    offensive and defensive agent servers. Your code then uses the HFO
Matthew Hausknecht's avatar
Matthew Hausknecht committed
86 87
    interface to connect your agent to the server. Once all agents are
    connected, the game begins. The trainer oversees the game.}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
  \label{fig:hfo}
\end{figure}

\section{Basic Usage}

RoboCup 2D soccer is designed to be played between two teams of
autonomous agents who communicate with a game server. Shown in Figure
\ref{fig:hfo}, the HFO domain reflects these design choices and allows
arbitrary teams to be created consisting of some mix of
non-player-controlled agents (agent2d npcs) and player-controlled
agents. These options are specified through the following flags:\\

\noindent
\verb+ > ./bin/HFO --offense-agents=1 --defense-agents=1 --offense-npcs=2 --defense-npcs=2+\\

Matthew Hausknecht's avatar
Matthew Hausknecht committed
103 104 105 106
This would create a 3v3 game with one player-controlled agent on each
team. In order for the game to start, you must connect your
player-controlled agents to the server. This is done through the
call:\\
Matthew Hausknecht's avatar
Matthew Hausknecht committed
107

Matthew Hausknecht's avatar
Matthew Hausknecht committed
108
\noindent \verb+  > hfo.connectToServer(FEATURE_SET, port, etc);+\\
Matthew Hausknecht's avatar
Matthew Hausknecht committed
109

Matthew Hausknecht's avatar
Matthew Hausknecht committed
110
The arguments to this function are provided by the HFO executable for
111 112 113
each player upon starting the game. For example
\verb|./bin/HFO --offense-agents=1| prints all the information needed
to connect the offensive player:\\
Matthew Hausknecht's avatar
Matthew Hausknecht committed
114

115 116
\noindent \verb+Waiting for player-controlled agent base_left-0: +\\
\noindent \verb+  config_dir=HFO/bin/teams/base/config/formations-dt,+\\
117
\noindent \verb+  server_port=6000, server_addr=localhost,+\\
118
\noindent \verb+  team_name=base_left, play_goalie=False+\\
Matthew Hausknecht's avatar
Matthew Hausknecht committed
119 120

By default, the server starts on port 6000, but may be changed as follows:\\
Matthew Hausknecht's avatar
Matthew Hausknecht committed
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142

\noindent \verb+  > ./bin/HFO --port 12345+

\section{Visualizer}

The SoccerWindow2 Visualizer allows a live game to be viewed as it
progresses. By default, the visualizer is enabled. However, the game
will likely proceed at a pace too fast for meaningful watching. To
enforce a standard pace, disable sync-mode:\\

\noindent \verb+  > ./bin/HFO --no-sync+\\

To disable visualization altogether, run in headless mode:\\

\noindent \verb+  > ./bin/HFO --headless+\\

The visualizer may also be used after the end of a game by replaying
logs, as discussed in the next section.

\section{Logging}

By default, the soccer server generates game logs and stores them in
Matthew Hausknecht's avatar
Matthew Hausknecht committed
143 144 145
the \verb+log+ directory. The main game logs are rcg files:
\verb+log/*.rcg+. These log may be replayed using the soccerwindow2
visualizer. \\
Matthew Hausknecht's avatar
Matthew Hausknecht committed
146 147 148 149 150 151 152 153 154 155

\noindent To replay a log: \\
\verb+  > ./bin/soccerwindow2 -l log/incomplete.rcg+

\noindent To disable logging:\\
\verb+  > ./bin/HFO --no-logging +

\noindent To change the logging directory:\\
\verb+  > ./bin/HFO --log-dir /path/to/new/dir +

156 157 158 159 160 161 162 163 164 165
\section{Making Videos}
It is possible to make videos from logs by saving frames from
SoccerWindow2. It helps to full-screen SoccerWindow2 before making a
video as it will save higher quality images. There are also several
display options under View $\rightarrow$ View Preference $\rightarrow$
Show that toggle what will be displayed. Saving frames can be done by
File $\rightarrow$ Save Image. To convert the saved pngs into a
movie:\\

\noindent \verb+ avconv -r 10 -start_number 0 -i 3v3/image-%05d.png -f mp4 -c:v libx264+\\
166
\noindent \verb+ -s 1024x768 -vf "crop=iw/2.5:8.38*ih/10:iw/2:ih/10,transpose=1" +\\
167 168 169 170 171 172 173
\noindent \verb+ -pix_fmt yuv420p test.mp4 +\\

This command autocrops offensive half of the playfield and rotates it
90 degrees. Avconv can be replaced by ffmpeg. Start number specifies
the number of the first frame. yuv420p pix format for OSX
compatibility.

Matthew Hausknecht's avatar
Matthew Hausknecht committed
174 175
\section{Recording}

176 177
It is possible to record the state perceptions (low- or high-level depending on
the player), low-level actions, and game status of all players:\\
Matthew Hausknecht's avatar
Matthew Hausknecht committed
178 179 180 181 182 183 184

\noindent \verb+  > ./bin/HFO --record + \\

This will produce logs for all the offensive players
(\verb+log/left-[1-11].log+) and defensive players
(\verb+log/right-[1-11].log+). The first offensive player is left-11,
so in the case of single-agent offense, left-11.log will contain the
Matthew Hausknecht's avatar
Matthew Hausknecht committed
185 186 187 188 189
active player's record. Note that for player controlled agents, it is
necessary to specify a \verb+record_dir+ in the \verb+connectToServer+
function:\\
\\
\noindent \verb+std::string record_dir = "log/";+\\
190
\noindent \verb+hfo.connectToServer(features, config_dir, port, server_addr,+\\
Matthew Hausknecht's avatar
Matthew Hausknecht committed
191
\noindent \verb+                    team_name, goalie, record_dir);+\\
Matthew Hausknecht's avatar
Matthew Hausknecht committed
192 193 194 195 196 197 198 199

\section{Randomness}
A seed may be specified as follows:\\

\noindent \verb+  > ./bin/HFO --seed 123+\\

This seed will determine the placement of the players and the ball at
the beginning of each episode. Due to non-determinism in the player
Matthew Hausknecht's avatar
Matthew Hausknecht committed
200 201 202
policies, it is not sufficient to precisely replicate full games. It
\textit{only} replicates the starting conditions for each episode. The
player's behavior, observations, and physics all proceed
Matthew Hausknecht's avatar
Matthew Hausknecht committed
203
stochastically.
204

Matthew Hausknecht's avatar
Matthew Hausknecht committed
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
\section{Player On Ball}
By default, episodes begin with the ball being randomly positioned in
the offensive half of the playfield. Typically the first task for the
offense is to send a player to collect the ball. It is possible to
instead request that a certain offensive player is given the ball at
the start of each episode. This is accomplished as follows:\\

\noindent \verb+  > ./bin/HFO --offense-on-ball 1+\\

The above command will always give the ball to the first offensive
player (e.g. uniform number 11). If an offense-on-ball number is
specified that is larger than the number of offensive players, the
ball will be given to a random offensive player at the start of each
episode.

\section{Teams}
By default, offensive and defensive NPCs use the base Agent2D
policy. It is possible to use policies from different teams as
follows:\\

\noindent \verb+  > ./bin/HFO --offense-team helios+\\
\noindent \verb+  > ./bin/HFO --defense-team base+\\

This would take offense NPCs from Helios' 2013 Eindhoven release and
defensive NPCs from the default Agent2D-base. Currently the only
supported teams are Helios and Base.

\section{Communication}
HFO allows agents to receive and broadcast messages. This is
accomplished by the \verb hear \ and \verb say \ functions. The
maximum allowed message size is controlled by HFO's
\verb|--message-size| flag. See
\verb|examples/communication_agent.cpp| and
\verb|examples/communication_agent.py| for examples.

Matthew Hausknecht's avatar
Matthew Hausknecht committed
240 241 242 243 244 245
\section{Fullstate}
By default, perceptions and actions in HFO are noisy. The
\verb+ --fullstate+ flag in HFO removes noise from the agent's
perception of the world. Many tasks become significantly easier as a
result. Noise in actions remains. This flag is disabled by default.

Matthew Hausknecht's avatar
Matthew Hausknecht committed
246 247 248 249 250 251 252 253 254
\section{Controlling Trials}
HFO trials typically end with a goal, the defense capturing the ball,
the ball going out of bounds, or running out of time. The trials flag
specifies a maximum number of trials
\verb+ > ./bin/HFO --trials 500+. Instead, a maximum number of frames
may be specified: \verb+ > ./bin/HFO --frames 1000+ will stop the
server after 10,000 steps have passed. Each trial is run for a maximum
of \verb --frames-per-trial \ steps, but may stop early if no agent
approaches the ball within \verb --untouched-time \ steps.
255

Matthew Hausknecht's avatar
Matthew Hausknecht committed
256 257 258 259
\section{State Spaces}
The HFO domains provides a choice between a low and a high-level
feature set. Selecting between the different feature sets is
accomplished when connecting the agent to the server:
Matthew Hausknecht's avatar
Matthew Hausknecht committed
260 261

\begin{verbatim}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
262 263
  > hfo.connectToServer(LOW_LEVEL_FEATURE_SET, ...);
  > hfo.connectToServer(HIGH_LEVEL_FEATURE_SET, ...);
Matthew Hausknecht's avatar
Matthew Hausknecht committed
264
\end{verbatim}
265

Matthew Hausknecht's avatar
Matthew Hausknecht committed
266 267 268 269 270 271
See \verb|examples/hfo_example_agent.cpp| and
\verb|examples/hfo_example_agent.py| for examples. As the choice of
feature set influences the challenge of learning, it is the
responsibility of the user to faithfully report which state space was
used. The following sections explain the feature sets.

272 273 274 275 276 277
\subsection{High Level Feature Set}
A set of high-level features is provided following the example given
by Barrett et al. pp. 159-160 \cite{THESIS14-Barrett}. Barrett writes
``There are many ways to represent the state of a game of half field
offense.  Ideally, we want a compact representation that allows the
agent to learn quickly by generalizing its knowledge about a state to
278 279 280 281
similar states without over-constraining the policy.'' All features
are encoded a floating point values and normalized to the range of
[-1,1]. Invalid features are given a value of -2. The features are as
follows:
282 283

\subsubsection{High Level State Feature List}
284 285 286
Let $T$ denote the number of teammates in the HFO game and $O$ the
number of opponents. There are a total of $10 + 6T + 3O$ high-level
features.
Matthew Hausknecht's avatar
Matthew Hausknecht committed
287 288

\begin{enumerate}[noitemsep]
289
\setcounter{enumi}{-1}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
290 291 292 293
\item{\textbf{X position} - The agent’s x-position on the field. See
  Figure \ref{fig:playfieldCoords}.}
\item{\textbf{Y position} - The agent’s y-position on the field. See
  Figure \ref{fig:playfieldCoords}.}
294
\item{\textbf{Orientation} - The global direction that the agent is facing.}
295 296
\item{\textbf{Ball X} - The ball's x-position on the field.}
\item{\textbf{Ball Y} - The ball's y-position on the field.}
297
\item{\textbf{Able to Kick} - Boolean indicating if the agent can kick the ball.}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
298
\item{\textbf{Goal Center Proximity} - Agent's proximity to the center of the goal.}
299
\item{\textbf{Goal Center Angle} - Angle from the agent to the center of the goal.}
300
\item{\textbf{Goal Opening Angle} - The size of the largest open angle
301
  of the agent to the goal, shown as $\theta_g$ in Figure
302
  \ref{fig:openAngle}. Invalid if agent is not playing offense.}
303 304 305 306 307 308
\item{\textbf{Proximity to Opponent} - If an opponent is present,
  proximity to the closest opponent. Invalid if there are no
  opponents.}
\item [$T$] {\textbf{Teammate's Goal Opening Angle} - For each
  teammate $i$: $i$’s goal opening angle. Invalid if agent is not
  playing offense.}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
309 310
\item [$T$] {\textbf{Proximity from Teammate i to Opponent} - For each
  teammate i: the proximity from the teammate to the closest
311 312
  opponent. This feature is invalid if there are no opponents or if
  teammates are present but not detected.}
313
\item [$T$] {\textbf{Pass Opening Angle} - For each teammate i: the open
314
  angle available to pass to teammate i. Shown as $\theta_p$ in Figure
315 316
  \ref{fig:openAngle}. If teammates are present but not detected, this
  feature is considered invalid and given the value of -2.}
317 318
\item [$3T$] {\textbf{X, Y, and Uniform Number of
    Teammates} - For each teammate: the x-position, y-position and
Matthew Hausknecht's avatar
Matthew Hausknecht committed
319
  uniform number of that teammate.}
320 321
\item [$3O$] {\textbf{X, Y, and Uniform Number of
    Opponents} - For each opponent: the x-position, y-position and
322
  uniform number of that opponent.}
323 324
\end{enumerate}

325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
\begin{figure}[htp]
  \centering
  \includegraphics[width=.7\textwidth]{figures/playfieldCoords}
  \caption{\textbf{Normalized Coordinates in the HFO play field}:
    These coordinates are used for reporting the agent's position in
    the high-level feature set as well specifying targets for the
    mid-level actions (Section \ref{sec:mid_level_actions}). The
    red-rectangle shows the boundaries of the reported positions,
    which exceed the play field boundaries by 10\% in each
    direction. Positions exceeding this rectangle are bounded (via
    min/max) to the edges of the rectangle. All distance features are
    normalized against the max HFO distance shown in orange.}
  \label{fig:playfieldCoords}
\end{figure}

340 341
\begin{figure}[htp]
  \centering
Matthew Hausknecht's avatar
Matthew Hausknecht committed
342
  \includegraphics[width=.5\textwidth]{figures/openAngle}
343 344 345 346 347 348 349 350
  \caption{Open angle from ball to the goal $\theta_g$ avoiding the
    blue goalie and the open angle from the ball to the yellow
    teammate $\theta_p$. Figure reproduced with permission from Samuel
    Barrett.}
  \label{fig:openAngle}
\end{figure}

\subsection {Low Level Feature Set}
351
The state features used by HFO are designed with the mindset of
Matthew Hausknecht's avatar
Matthew Hausknecht committed
352
providing an overcomplete, basic, egocentric viewpoint. The features
353 354 355 356 357 358
are basic in the sense that they provide distances and angles to
relevant points of interest, but do not include higher level
perceptions such as the largest angle between a goal post and
goalkeeper.

All features are encoded as floating point values normalized to the
Matthew Hausknecht's avatar
Matthew Hausknecht committed
359
range of [-1,1]. Several different types of features exist:
360

361
\subsubsection{Boolean Features}
362 363 364
Boolean features assume either the minimum feature value of -1 or the
maximum feature value of 1.

365
\subsubsection{Valid Features}
366 367 368 369 370 371 372 373 374 375 376 377 378
Since feature information is attained from the Agent's world-model, it
is possible that, the world model's information may be stale or
incorrect. \textit{Valid features} are boolean features indicating
consistency of world model predictions. For example, if the world
model's estimate of the agent's position is known to be flawed, the
\textit{valid feature} for self position would assume the minimum
value of -1. Otherwise it will assume the maximum value of 1.

The features associated with a valid feature are given the value of
zero if an inconsistency is detected. For example, if the world model
detects that the agent's velocity is invalid, the feature that encodes
the magnitude of self velocity will be set to zero.

379
\subsubsection{Angular Features}
380 381 382 383
\textit{Angular features} (e.g. the angle to the ball), are encoded as
two floating point numbers -- the $sin(\theta)$ and $cos(\theta)$
where $\theta$ is the original angle in radians. Figure
\ref{fig:ang_example} provides examples of the angular encoding.
384 385 386 387 388 389 390

This encoding allows the angle to vary smoothly for all possible
angular values. Other encodings such as radians or degrees have a
discontinuity that when normalized, could cause the feature value to
flip between the maximum and minimum value in response to small
changes in $\theta$.

391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418
Given an angular feature $\langle \alpha_1, \alpha_2 \rangle$ we can
recover the original angle $\theta$ (in radians) by taking the
$cos^{-1}(\alpha_2)$ and multiplying by the sign of $\alpha_1$.

\begin{figure*}[htp]
  \centering
  \subcaptionbox{Angular Encoding}{
    \includegraphics[width=.4\textwidth]{figures/AngExample}
  }
  \hspace{3em}
  \subcaptionbox{Additional Examples}{
    \includegraphics[width=.3\textwidth]{figures/AngFeatExample}
  }
  \caption{\textbf{Angular Encoding:} Objects on the agents left/right
    side result in a negative/positive $sin(\theta)$. $cos(\theta)$ is
    positive in front of the player and negative behind. For example,
    an object directly in front of the player would have angular
    features of $sin(\theta)=0, cos(\theta)=1$. Additional examples:
    \textbf{Angle to ball} $\theta=60^\circ$ or $1.0472$ radians. This
    results in angular features $\langle sin(\theta)=.86,
    cos(\theta)=.49 \rangle$. \textbf{Angle to teammate}:
    $\theta=135^\circ, 2.35$ radians. $\langle sin(\theta)=.71,
    cos(\theta)=-.71 \rangle$. \textbf{Angle to Opponent}:
    $\theta=-90^\circ$ or $-1.57$ radians. $\langle sin(\theta)=-1,
    cos(\theta)=0 \rangle$.}
  \label{fig:ang_example}
\end{figure*}

Matthew Hausknecht's avatar
Matthew Hausknecht committed
419 420 421 422 423 424 425 426
\subsubsection{Proximity Features}
\textit{Proximity features} encode the proximity of the agent to an
object of interest. Unless otherwise indicated, they are normalized
against the maximum possible distance in the HFO playfield (defined as
$\sqrt{l^2 + w^2}$ where $l,w$ are the length and width of the HFO
playfield). A maximum proximity of 1 indicates the agent is co-located
with the object of interest, while a minimum proximity of -1 indicates
that the agent is across the field from the object of interest.
427

428
\subsubsection{Landmark Features}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
429 430 431 432 433 434
Landmark features encode the relative angle and proximity of the agent
to a landmark of interest. Each landmark feature consists of three
floating point values, two to encode the agent's relative angle to the
landmark and one to encode the landmark's proximity. Note that if the
agent's self position is invalid, then the landmark feature values are
zeroed.
435

436
\subsubsection{Player Features}
437 438 439 440 441 442 443
Player features are used to encode the relationship of the agent to
another player or opponent. Each player feature is encoded as 1) a
landmark feature of that player's location 2) the global angle of that
player's body 3) the magnitude of the player's velocity and 4) the
global angle of the player's velocity. Eight floating point numbers
are used to encode each player feature.

444 445 446 447 448 449 450 451 452 453
\subsubsection{Uniform Number Features}
In the low-level feature space, unknown uniform numbers, or \textit{unums},
are encoded as -1, while known ones are encoded as $\frac{unum}{100}$, thus
remaining well within the $[-1, 1]$ range. (Note that roundoff error may need
to be allowed for when converting these back to integers, such as for use in
high-level actions; e.g., 0.0799 will need to be converted back to 8.)
Uniform number features, a later addition to the low-level feature space,
are positioned after all other features to hopefully ensure compatibility
with older programs.

454
\subsubsection{Other Features}
455 456
Some features, such as the agent's stamina, do not fall into any of
the above categories. These features are referred to as \textit{other
457
  features} and are normalized in the range $[-1, 1]$.
458

459
\subsubsection{Low Level State Feature List}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
460
Let $T$ denote the number of teammates and $O$ denote the number of
461
opponents in the HFO game. Then there are a total of $58 + 9T + 9O$
Matthew Hausknecht's avatar
Matthew Hausknecht committed
462
low-level features:
463

Matthew Hausknecht's avatar
Matthew Hausknecht committed
464
\begin{enumerate}[noitemsep]
465
\setcounter{enumi}{-1}
466 467
  \item{\textbf{Self\_Pos\_Valid} [Valid] Indicates if self position is valid.}
  \item{\textbf{Self\_Vel\_Valid} [Valid] Indicates if the agent's velocity is valid.}
468
  \itemrange{1}{\textbf{Self\_Vel\_Ang} [Angle] Angle of agent's velocity.}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
469
  \item{\textbf{Self\_Vel\_Mag} [Other] Magnitude of the agent's velocity.}
470
  \itemrange{1}{\textbf{Self\_Ang} [Angle] Agent's Global Body Angle.}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
471
  \item{\textbf{Stamina} [Other] Agent's Stamina: Low stamina slows movement.}
472
  \item{\textbf{Frozen} [Boolean] Indicates if the agent is Frozen. Frozen status can
Matthew Hausknecht's avatar
Matthew Hausknecht committed
473 474
    happen when tackling or being tackled by another player.}
  \item{\textbf{Colliding\_with\_ball} [Boolean] Indicates the agent
475
    is colliding with the ball.}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
476
  \item{\textbf{Colliding\_with\_player} [Boolean] Indicates the agent
477
    is colliding with another player.}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
478
  \item{\textbf{Colliding\_with\_post} [Boolean] Indicates the agent
479
    is colliding with a goal post.}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
480
  \item{\textbf{Kickable} [Boolean] Indicates the agent is able to
481
    kick the ball.}
482 483 484 485 486 487 488
  \itemrange{2}{\textbf{Goal Center} [Landmark] Center point between the goal posts.}
  \itemrange{2}{\textbf{Goal Post Top} [Landmark] Top goal post.}
  \itemrange{2}{\textbf{Goal Post Bot} [Landmark] Bottom goal post.}
  \itemrange{2}{\textbf{Penalty Box Center} [Landmark] Center of the penalty box line.}
  \itemrange{2}{\textbf{Penalty Box Top} [Landmark] Top corner of the penalty box.}
  \itemrange{2}{\textbf{Penalty Box Bot} [Landmark] Bottom corner of the penalty box.}
  \itemrange{2}{\textbf{Center Field} [Landmark] The left middle point of the
Matthew Hausknecht's avatar
Matthew Hausknecht committed
489
    HFO play area.}
490 491 492 493
  \itemrange{2}{\textbf{Corner Top Left} [Landmark] Top left corner HFO Playfield.}
  \itemrange{2}{\textbf{Corner Top Right} [Landmark] Top right corner HFO Playfield.}
  \itemrange{2}{\textbf{Corner Bot Right} [Landmark] Bot right corner HFO Playfield.}
  \itemrange{2}{\textbf{Corner Bot Left} [Landmark] Bot left corner HFO Playfield.}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
494
  \item{\textbf{OOB Left Dist} [Proximity] Proximity to the nearest
495 496
    point of the left side of the HFO playable area. E.g. distance
    remaining before the agent goes out of bounds in left field.}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
497 498 499 500 501 502 503 504 505
  \item{\textbf{OOB Right Dist} [Proximity] Proximity to the right
    field line.}
  \item{\textbf{OOB Top Dist} [Proximity] Proximity to the top field line.}
  \item{\textbf{OOB Bot Dist} [Proximity] Proximity to the bottom field line.}
  \item{\textbf{Ball Pos Valid} [Valid] Indicates the ball position estimate is valid.}
  \itemrange{1}{\textbf{Ball Angle} [Angle] Agent's angle to the ball.}
  \item{\textbf{Ball Dist} [Proximity] Proximity to the ball.}
  \item{\textbf{Ball Vel Valid} [Valid] Indicates the ball velocity estimate is valid.}
  \item{\textbf{Ball Vel Mag} [Other] Magnitude of the ball's velocity.}
506 507 508
  \itemrange{1}{\textbf{Ball Vel Ang} [Angle] Global angle of ball velocity.}
  \item [$8T$] {\textbf{Teammate Features} [Player] One teammate feature set (8 features) for each teammate active in HFO, sorted by proximity to the agent.}
  \item [$8O$] {\textbf{Opponent Features} [Player] One opponent feature set (8 features) for each opponent present, sorted by proximity to the player.}
509 510
  \item [$T$]  {\textbf{Teammate Uniform Nums} [Unum] One uniform number for each teammate active in HFO, sorted by proximity to the agent.}
  \item [$O$]  {\textbf{Opponent Uniform Nums} [Unum] One uniform number for each opponent present, sorted by proximity to the player.}
511
\end{enumerate}
512 513

\section{Action Space}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
514 515 516 517 518 519 520 521 522 523 524
The HFO domain provides support for both low-level primitive actions,
mid-level, and high-level strategic actions. Low-level, parameterized
actions are provided for locomotion and kicking. Mid-level actions are
still parameterized by capture high level activities such as
dribbling. Finally, high-level discrete, strategic actions are
available for moving, shooting, passing and dribbling. Control of the
agent's head and gaze is not provided and follows Agent2D's default
strategy. Low, medium, and high level actions are available through
the same interface. As the choice of action spaces greatly influences
the challenge of learning, it is the responsibility of the user to
faithfully report which action spaces were used.
525 526

\subsection{Low Level Actions}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
527
\label{sec:low_level_actions}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
528
\begin{itemize}[noitemsep]
529 530 531 532 533 534 535 536 537
\item{\textbf{Dash}(power, degrees): Moves the agent with power [-100,
    100] where negative values move backwards. The relative direction
  of movement is given in degrees and varies between [-180,180] with 0
  degrees being a forward dash and 90 degrees dashing to the agent's
  right side. Note, dashing does not turn the agent.}
\item{\textbf{Turn}(degrees): Turns the agent in the
  specified direction. Valid values range between [-180, 180] degrees
  where 90 degrees turns the agent to directly to its right side.}
\item{\textbf{Tackle}(degrees): Contest the ball. Direction
Matthew Hausknecht's avatar
Matthew Hausknecht committed
538
  varies between [-180, 180].}
539 540 541
\item{\textbf{Kick}(power, degrees): Kick the ball with power [0, 100]
  in relative direction [-180, 180]. Has no effect if the agent does
  not possess the ball.}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
542 543 544 545
\end{itemize}

\subsection{Mid Level Actions}
\label{sec:mid_level_actions}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
546
\begin{itemize}[noitemsep]
Matthew Hausknecht's avatar
Matthew Hausknecht committed
547 548 549 550 551 552 553 554 555 556 557 558 559
\item{\textbf{Kick$\_$To}(target$_x$, target$_y$, speed): Kicks the
  ball to the specified target point with the desired speed. Valid
  values for target$_{x,y} \in [-1,1]$ and speed $\in [0,3]$.}
\item{\textbf{Move$\_$To}(target$_x$, target$_y$): Moves to the
  specified target point using the max dash speed. Valid values for
  target$_{x,y} \in [-1,1]$.}
\item{\textbf{Dribble$\_$To}(target$_x$, target$_y$): Dribbles the
  ball to the specified target point. Attempts to fetch the ball if
  the agent doesn't already possess it. Performs some checks to avoid
  opponents and keeps good control of the ball. Valid values for
  target$_{x,y} \in [-1,1]$.}
\item{\textbf{Intercept}(): Moves to intercept the ball, taking into
  account the ball velocity. More efficient than chasing the ball.}
560 561
\end{itemize}

562
\subsection{High Level Actions}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
563
\label{sec:high_level_actions}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
564
\begin{itemize}[noitemsep]
565 566 567 568 569 570 571
\item{\textbf{Move}(): Re-positions the agent according to the
  strategy given by Agent2D. The \textit{move} command works only when
  agent does not have the ball. If the agent has the ball, another
  command such as \textit{dribble}, \textit{shoot}, or \textit{pass}
  should be used.}
\item{\textbf{Shoot}(): Executes the best available shot. This command
  only works when the agent has the ball.}
572 573 574 575
\item{\textbf{Pass}(teammate\_uniform\_number): Passes to the teammate
  with the provided uniform number. Does nothing if the player does
  not have control of the ball or the requested teammate is not
  detected.}
576 577
\item{\textbf{Dribble}(): Advances the ball towards the goal using a
  combination of short kicks and moves.}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
578 579
\item{\textbf{Catch}(): This goalie-specific action may be used to
  catch the ball.}
580 581 582 583 584 585 586 587 588
\item {\textbf{Reduce\_Angle\_To\_Goal} (): Moves the agent to a point on the field, such that the kicker has the least open angle to the goal. }


\item {\textbf{Defend\_Goal} () : Moves the agent to a point on a fixed line on the field, such that the kicker has the least open angle to the goal.}

\item {\textbf{Go\_To\_Ball} (): Makes the agent go towards the ball.}

\item {\textbf{Mark\_Player} (uniform\_number): Moves the agent so as to mark the player with the specified uniform number.}

589 590
\end{itemize}

Matthew Hausknecht's avatar
Matthew Hausknecht committed
591
\subsection{Special Actions}
Matthew Hausknecht's avatar
Matthew Hausknecht committed
592
\begin{itemize}[noitemsep]
Matthew Hausknecht's avatar
Matthew Hausknecht committed
593 594 595 596 597
\item{\textbf{NO-OP}: Indicates that the agent should take no action.}
\item{\textbf{Quit}: Indicates to the agent server that you wish to
  terminate the HFO environment.}
\end{itemize}

598 599 600 601 602 603 604 605 606 607 608
\subsection{Available Actions}
The Special Actions are always available. The below table indicates whether
other actions are available (only if there are no ``N''s indicated); check
below the table for the action abbreviations.

\begin{center}
{\footnotesize
\begin{tabular}{r         c     c      c    c     c     c      c     c     c    c    c     c     c     c     c     c     c}
Action                  & Da  & Tu  &  Ta & K   & KT &  MT  &  DT &  I  &  M  & S  & P  &  Dr  & C  &  RG &  DG  & G  &  MP \\
\hline
Self position invalid   & Y   &  Y  &  Y  &  Y  & N  &  N   &  N? &  N? &  N? & N? & ?  &  Y?  & ?  &  N? &  N?  & ?  &  ? \\
609
Self velocity invalid   & Y?  &  Y? &  Y? &  Y? & ?  &  N?  &  ?  &  N? &  N? & N? & ?  &  Y?  & ?  &  ?  &  ?   & ?  &  ? \\
610
Ball position invalid   & Y   &  Y  &  Y  &  N  & N  &  Y   &  N? &  N  &  ?  & N  & N  &  Y?  & N  &  ?  &  ?   & N  &  ? \\
611
Ball velocity invalid   & Y   &  Y  &  Y  &  ?  & ?  &  Y   &  ?  &  N? &  ?  & N  & N? &  Y?  & N? &  Y? &  Y?  & Y? &  Y? \\
612 613 614 615 616 617 618 619 620 621 622
Teammate loc invalid    & Y   &  Y  &  Y  &  Y  & Y  &  Y   &  Y  &  Y  &  ?  & Y  & N  &  Y?  & Y  &  Y  &  Y   & Y  &  Y \\
Teammate unum invalid   & Y   &  Y  &  Y  &  Y  & Y  &  Y   &  Y  &  Y  &  Y  & Y  & N  &  Y   & Y  &  Y  &  Y   & Y  &  Y \\
Opponent loc invalid    & Y   &  Y  &  Y  &  Y  & Y  &  Y   &  Y? &  Y  &  ?  & Y? & Y  &  Y?  & Y  &  N  &  N   & Y  &  N \\
Opponent unum invalid   & Y   &  Y  &  Y  &  Y  & Y  &  Y   &  Y  &  Y  &  Y  & Y  & Y  &  Y   & Y  &  Y  &  Y   & Y  &  N \\
Ball kickable           & Y   &  Y  &  ?  &  Y  & Y  &  Y   &  Y  &  N? &  N  & Y  & Y  &  Y   & Y  &  N? &  N?  & N? &  Y? \\
Ball not kickable       & Y   &  Y  &  Y  &  N  & N  &  Y   &  Y  &  Y  &  Y  & N  & N  &  N   & Y  &  Y  &  Y   & Y  &  Y \\
Frozen                  & N   &  N  &  N? &  N  & N  &  N   &  N? &  N  &  N? & N  & N  &  Y?  & N? &  N  &  N   & N  &  N \\
Colliding with ball     & ?   &  ?  &  N? &  ?  & ?  &  ?   &  ?  &  N? &  ?  & ?  & ?  &  ?   & ?  &  ?  &  ?   & ?  &  ? \\
Colliding with player   & ?   &  ?  &  ?  &  N? & N? &  ?   &  ?  &  N? &  ?  & ?  & ?  &  Y?  & ?  &  ?  &  ?   & ?  &  ? \\
Colliding with post     & ?   &  ?  &  N? &  N? & N? &  ?   &  ?  &  N? &  ?  & ?  & ?  &  ?   & ?  &  ?  &  ?   & ?  &  ? \\
Offense                 & Y   &  Y  &  ?  &  Y  & Y  &  Y   &  Y  &  Y  &  Y  & Y  & Y  &  Y   & N  &  N  &  N   & Y  &  N \\
623
Defense, not goalie     & Y   &  Y  &  ?  &  N? & N? &  Y   &  N  &  Y  &  ?  & N  & N  &  N   & N  &  Y  &  ?   & Y  &  Y \\
624 625 626 627 628 629 630 631
Goalie (defense)        & Y   &  Y  &  ?  &  N? & N? &  Y   &  N  &  Y  &  ?  & N  & N  &  N   & Y  &  ?  &  ?   & ?  &  ? \\
\end{tabular}
}
\end{center}
Da: Dash; Tu: Turn; Ta: Tackle; K: Kick \\
KT: Kick\_To; MT: Move\_To; DT: Dribble\_To; I: Intercept \\
M: Move; S: Shoot; P: Pass; Dr: Dribble; C: Catch; RG: Reduce\_Angle\_To\_Goal; DG: Defend\_Goal; G: Go\_To\_Ball; MP: Mark\_Player

Matthew Hausknecht's avatar
Matthew Hausknecht committed
632 633 634 635 636 637
\section{Developing a New Agent}

New agents may be developed in C++ or Python. In Python, as long as
the hfo interface has been installed, the agent needs only to
\verb+from hfo import *+. In C++ it is necessary to
\verb+#include <HFO.hpp>+ and also to link against the shared object
Matthew Hausknecht's avatar
Matthew Hausknecht committed
638
library \verb+lib/libhfo.so+ when compiling:
Matthew Hausknecht's avatar
Matthew Hausknecht committed
639 640 641 642 643

\begin{verbatim}
  > g++ example/your_new_agent.cpp -I src -L lib -Wl,-rpath=lib -lhfo
\end{verbatim}

644 645 646
\bibliographystyle{abbrv}
\bibliography{manual}

647
\end{document}