Title: EMERGENT COORDINATION THROUGH COMPETITION

Abstract: We study the emergence of cooperative behaviors in reinforcement learning agents by introducing a challenging competitive multi-agent soccer environment with continuous simulated physics. We demonstrate that decentralized, populationbased training with co-play can lead to a progression in agents' behaviors: from random, to simple ball chasing, and finally showing evidence of cooperation. Our study highlights several of the challenges encountered in large scale multi-agent training in continuous control. In particular, we demonstrate that the automatic optimization of simple shaping rewards, not themselves conducive to co-operative behavior, can lead to long-horizon team behavior. We further apply an evaluation scheme, grounded by game theoretic principals, that can assess agent performance in the absence of pre-defined evaluation tasks or human baselines.

1. INTRODUCTION:

Competitive games have been grand challenges for artificial intelligence research since at least the 1950s (Samuel, 1959; Tesauro, 1995; Campbell et al., 2002; Vinyals et al., 2017) . In recent years, a number of breakthroughs in AI have been made in these domains by combining deep reinforcement learning (RL) with self-play, achieving superhuman performance at Go and Poker (Silver et al., 2016; Moravk et al., 2017) . In continuous control domains, competitive games possess a natural curriculum property, as observed in Bansal et al. (2017) , where complex behaviors have the potential to emerge in simple environments as a result of competition between agents, rather than due to increasing difficulty of manually designed tasks. Challenging collaborative-competitive multi-agent environments have only recently been addressed using end-to-end RL by Jaderberg et al. (2018) , which learns visually complex first-person 2v2 video games to human level. One longstanding challenge in AI has been robot soccer (Kitano et al., 1997) , including simulated leagues, which has been tackled with machine learning techniques (Riedmiller et al., 2009; MacAlpine & Stone, 2018) but not yet mastered by end-to-end reinforcement learning.

We investigate the emergence of co-operative behaviors through multi-agent competitive games. We design a simple research environment with simulated physics in which complexity arises primarily through competition between teams of learning agents. We introduce a challenging multi-agent soccer environment, using MuJoCo (Todorov et al., 2012) which embeds soccer in a wider universe of possible environments with consistent simulated physics, already used extensively in the machine learning research community (Heess et al., 2016; 2017; Bansal et al., 2017; Brockman et al., 2016; Tassa et al., 2018; Riedmiller et al., 2018) . We focus here on multi-agent interaction by using relatively simple bodies with a 3-dimensional action space (though the environment is scalable to more agents and more complex bodies). 1 We use this environment to examine continuous multiagent reinforcement learning and some of its challenges including coordination, use of shaping rewards, exploitability and evaluation.

We study a framework for continuous multi-agent RL based on decentralized population-based training (PBT) of independent RL learners (Jaderberg et al., 2017; 2018) , where individual agents learn off-policy with recurrent memory and decomposed shaping reward channels. In contrast to some recent work where some degree of centralized learning was essential for multi-agent coordinated behaviors (e.g. Lowe et al., 2017; Foerster et al., 2016) , we demonstrate that end-to-end PBT can lead to emergent cooperative behaviors in our soccer domain. While designing shaping rewards that induce desired cooperative behavior is difficult, PBT provides a mechanism for automatically evolving simple shaping rewards over time, driven directly by competitive match results. We further suggest to decompose reward into separate weighted channels, with individual discount factors and automatically optimize reward weights and corresponding discounts online. We demonstrate that PBT is able to evolve agents' shaping rewards from myopically optimizing dense individual shaping rewards through to focusing relatively more on long-horizon game rewards, i.e. individual agent's rewards automatically align more with the team objective over time. Their behavior correspondingly evolves from random, through simple ball chasing early in the learning process, to more co-operative and strategic behaviors showing awareness of other agents. These behaviors are demonstrated visually and we provide quantitative evidence for coordination using game statistics, analysis of value functions and a new method of analyzing agents' counterfactual policy divergence.

Finally, evaluation in competitive multi-agent domains remains largely an open question. Traditionally, multi-agent research in competitive domains relies on handcrafted bots or established human baselines (Jaderberg et al., 2018; Silver et al., 2016) , but these are often unavailable and difficult to design. In this paper, we highlight that diversity and exploitability of evaluators is an issue, by observing non-transitivities in the agents pairwise rankings using tournaments between trained teams. We apply an evaluation scheme based on Nash averaging (Balduzzi et al., 2018) and evaluate our agents based on performance against pre-trained agents in the support set of the Nash average.

2. PRELIMINARIES:

We treat our soccer domain as a multi-agent reinforcement learning problem (MARL) which models a collection of agents interacting with an environment and learning, from these interactions, to optimize individual cumulative reward. MARL can be cooperative, competitive or some mixture of the two (as is the case in soccer), depending upon the alignment of agents' rewards. MARL is typically modelled as a Markov game (Shapley, 1953; Littman, 1994) , which comprises: a state space S, n agents with observation and action sets O 1 , ..., O n and A 1 , ..., A n ; a (possibly stochastic) reward function R i : S × A i → R for each agent; observation functions φ i : S → O i ; a transition function P which defines the conditional distribution over successor states given previous state-actions: P (S t+1 |S t , A 1 t , ..., A n t ), which satisfies the Markov property P (S t+1 |S τ , A 1 τ , ..., A n τ , ∀τ ≤ t) = P (S t+1 |S t , A 1 t , ..., A n t ); and a start state distribution P 0 (S 0 ) on S. In our application the state and action sets are continuous, and the transition distributions should be thought of as densities. Each agent i sequentially chooses actions, a i t , at each timestep t, based on their observations, φ i t = φ i (s t ), and these interactions give rise to a trajectory ((s t , a 1 t , ..., a n t , r 1 t , ..., r n t )) t=1,2,...,H , over a horizon H, where at each time step S t+1 ∼ P (•|s t , a 1 t , ..., a n t ), and r i t = R i (s t , a i t ). Each agent aims to maximize expected cumulative reward, E[ H t=0 γ t r i t ] (discounted by a factor γ < 1 to ensure convergence when H is infinite), and chooses actions according to a policy a i t ∼ π i (•|x i t ), which in general can be any function of the history x i t of the agent's prior observations and actions at time t,

x i t := (φ i (s 1 ), a i 1 , ..., φ i (s t-1 ), a i t-1 , φ i (s t )).

The special case of a Markov game with one agent is a partially-observed Markov decision process (POMDP) (Sutton & Barto, 1998) . In this work all players have the same action and observation space.

3. METHODS:

We seek a method of training agents which addresses the exploitability issues of competitive games, arising from overfitting to a single opponents policy, and provides a method of automatically optimizing hyperparameters and shaping rewards online, which are otherwise hard to tune. Following Jaderberg et al. (2018) , we combine algorithms for single-agent RL (in our case, SVG0 for continuous control) with population-based training (PBT) (Jaderberg et al., 2017) . We describe the individual components of this framework, and several additional novel algorithmic components introduced in this paper.

3.1. POPULATION BASED TRAINING:

Population Based Training (PBT) (Jaderberg et al., 2017) was proposed as a method to optimize hyperparameters via a population of simultaneously learning agents: during training, poor performing end while 22: end procedure agents, according to some fitness function, inherit network parameters and some hyperparameters from stronger agents, with additional mutation. Hyperparameters can continue to evolve during training, rather than committing to a single fixed value (we show that this is indeed the case in Section 5.1). PBT was extended to incorporate co-play (Jaderberg et al., 2018) as a method of optimizing agents for MARL: subsets of agents are selected from the population to play together in multi-agent games. In any such game each agent in the population effectively treats the other agents as part of their environment and learns a policy π θ to optimize their expected return, averaged over such games. In any game in which π θ controls player i in the game, if we denote by π \i := {π j } j∈{1,2,...,n},j =i the policies of the other agents j = i, we can write the expected cumulative return over a game as

J i (π θ ; π \i ) := E H t=0 γ t r i t π i = π θ , π \i (1)

where the expectation is w.r.t. the environment dynamics and conditioned on the actions being drawn from policies π θ and π \i . Each agent in the population attempts to optimize (1) averaged over the draw of all agents from the population P, leading to the PBT objective J(π θ ) :=

E i [E π \i ∼P [J i (π θ ; π \i )|π i = π θ ]],

where the outer expectation is w.r.t. the probability that the agent with policy π θ controls player i in the environment, and the inner expectation is the expectation over the draw of other agents, conditioned on π θ controlling player i in the game. PBT achieves some robustness to exploitability by training a population of learning agents against each other. Algorithm 1 describes PBT-MARL for a population of N agents {A i } i∈[1,..,N ] , employed in this work.

3.2. RETRACE-SVG0:

Throughout our experiments we use Stochastic Value Gradients (SVG0) (Heess et al., 2015b) as our reinforcement learning algorithm for continuous control. This is an actor-critic policy gradient algorithm, which in our setting is used to estimate gradients ∂ ∂θ J i (π θ ; π \i ) of the objective (1) for each game. Averaging these gradients over games will effectively optimize the PBT objective J(π θ ). Policies are additionally regularized with an entropy loss H(π) i.e. we maximize Ĵ(π θ ) := J(π θ ) + αH(π θ ) using the Adam optimizer (Kingma & Ba, 2014) to apply gradient updates where α represents a multiplicative entropy cost factor. A derivation of SVG0 is provided in Appendix A.

SVG utilizes a differentiable Q-critic. Our critic is learned using experience replay, minimizing a k-step TD-error with off-policy retrace corrections (Munos et al., 2016) , using a separate target network for bootstrapping, as is also described in Hausman et al. (2018) ; Riedmiller et al. (2018) . The identity of other agents π \i in a game are not explicitly revealed but are potentially vital for accurate action-value estimation (value will differ when playing against weak rather than strong opponents). Thus, we use a recurrent critic to enable the Q-function to implicitly condition on other players observed behavior, better estimate the correct value for the current game, and generalize over the diversity of players in the population of PBT, and, to some extent, the diversity of behaviors in replay. We find in practice that a recurrent Q-function, learned from partial unrolls, performs very well. Details of our Q-critic updates, including how memory states are incorporated into replay, are given in Appendix A.2.

3.3. DECOMPOSED DISCOUNTS AND ACTION-VALUE ESTIMATION FOR REWARD SHAPING:

Reinforcement learning agents learning in environments with sparse rewards often require additional reward signal to provide more feedback to the optimizer. Reward can be provided to encourage agents to explore novel states for instance (e.g. Brafman & Tennenholtz, 2001) , or some other form of intrinsic motivation. Reward shaping is particularly challenging in continuous control (e.g. Popov et al., 2017) where obtaining sparse rewards is often highly unlikely with random exploration, but shaping can perturb objectives (e.g. Bagnell & Ng, 2005) resulting in degenerate behaviors. Reward shaping is yet more complicated in the cooperative multi-agent setting in which independent agents must optimize a joint objective. Team rewards can be difficult to co-optimize due to complex credit assignment, and can result in degenerate behavior where one agent learns a reasonable policy before its teammate, discouraging exploration which could interfere with the first agent's behavior as observed by Hausknecht (2016). On the other hand, it is challenging to design shaping rewards which induce desired co-operative behavior.

We design n r shaping reward functions {r j : S × A → R} j=1,...,nr , weighted so that r(•) := nr j=1 α j r j (•) is the agent's internal reward and, as in Jaderberg et al. (2018) , we use populationbased training to optimize the relative weighting {α j } j=1,...,nr . Our shaping rewards are simple individual rewards to help with exploration, but which would induce degenerate behaviors if badly scaled. Since the fitness function used in PBT will typically be the true environment reward (in our case win/loss signal in soccer), the weighting of shaping rewards can in principle be automatically optimized online using the environment reward signal. One enhancement we introduce is to optimize separate discount factors {γ j } j=1,...,nr for each individual reward channel. The objective optimized is then (recalling Equation 1) J(π θ ; π \i ) := E nr j=1 α j H t=0 γ t j r j (s t , a 1 t , ..., a n t ) π i = π θ , π \i . This separation of discount factors enables agents to learn to optimize the sparse environment reward far in the future with a high discount factor, but optimize dense shaping rewards myopically, which would also make value-learning easier. This would be impossible if discounts were confounded. The specific shaping rewards used for soccer are detailed in Section 5.1.

4. EXPERIMENTAL SETUP:



4.1. MUJOCO SOCCER ENVIRONMENT:

We simulate 2v2 soccer using the MuJoCo physics engine (Todorov et al., 2012) . The 4 players in the game are a single sphere (the body) with 2 fixed arms, and a box head, and have a 3-dimensional action space: accelerate the body forwards/backwards, torque can be applied around the vertical axis to rotate, and apply downwards force to "jump". Applying torque makes the player spin, gently for steering, or with more force in order to "kick" the football with its arms. At each timestep, proprioception (position, velocity, accelerometer information), task (egocentric ball position, velocity and angular velocity, goal and corner positions) and teammate and opponent (orientation, position and velocity) features are observed making a 93-dimensional input observation vector. Each soccer match lasts upto 45 seconds, and is terminated when the first team scores. We disable contacts between the players, but enable contacts between the players, the pitch and the ball. This makes it impossible for players to foul and avoids the need for a complicated contact rules, and led to more dynamic matches. There is a small border around the pitch which players can enter, but when the ball is kicked out-of-bounds it is reset by automatic "throw in" a small random distance towards the center of the pitch, and no penalty is incurred. The players choose a new action every 0.05 seconds. At the start of an episode the players and ball are positioned uniformly at random on the pitch. We train agents on a field whose dimensions are randomized in the range 20m × 15m to 28m × 21m, with fixed aspect ratio, and are tested on a field of fixed size 24m × 18m. We show an example frame of the game in Figure 1 .

4.2. PBT SETTINGS:

We use population-based training with 32 agents in the population, an agent is chosen for evolution if its expected win rate against another chosen agent drops below 0.47. The k-factor learning rate for Elo is 0.1 (this is low, due to the high stochasticity in the game results). Following evolution there is a grace period where the agent does not learn while its replay buffer refills with fresh data, and a further "burn-in" period before the agent can evolve again or before its weights can be copied into another agent, in order to limit the frequency of evolution and maintain diversity in the population. For each 2v2 training match 4 agents were selected uniformly at random from the population of 32 agents, so that agents are paired with diverse teammates and opponents.

4.3. EVALUATION:

Unlike multi-agent domains where we possess hand-crafted bots or human baselines, evaluating agent performance in novel domains where we do not possess such knowledge remains an open question. A number of solutions have been proposed: for competitive board games, there exits evaluation metrics such as Elo (Elo, 1978) where ratings of two players should translate to their relative win-rates; in professional team sports, head-to-head tournaments are typically used to measure team performance; in Al-Shedivat et al. (2017) , survival-of-the-fittest is directly translated to multiagent learning as a proxy to relative agent performance. Unfortunately, as shown in Balduzzi et al. (2018) , in a simple game of rock-paper-scissors, a rock-playing agent will attain high Elo score if we simply introduce more scissor-play agents into a tournament. Survival-of-the-fittest analysis as shown in Al-Shedivat et al. (2017) would lead to a cycle, and agent ranking would depend on when measurements are taken (Tuyls et al., 2018) .

Nash-Averaging Evaluators: One desirable property for multi-agent evaluation is invariance to redundant agents: i.e. the presence of multiple agents with similar strategies should not bias the ranking. In this work, we apply Nash-averaging which possesses this property. Nash-Averaging consists of a meta-game played using a pair-wise win-rate matrix between N agents. A row player and a column player simultaneously pick distributions over agents for a mixed strategy, aiming for a non-exploitable strategy (see Balduzzi et al., 2018) .

In order to meaningfully evaluate our learned agents, we need to bootstrap our evaluation process. Concretely, we choose a set of fixed evaluation teams by Nash-averaging from a population of 10 teams previously produced by diverse training schemes, with 25B frames of learning experience each. We collected 1M tournament matches between the set of 10 agents. Figure 2 shows the pairwise expected goal difference among the 3 agents in the support set. Nash Averaging assigned nonzero weights to 3 teams that exhibit diverse policies with non-transitive performance which would not have been apparent under alternative evaluation schemes: agent A wins or draws against agent B on 59.7% of the games; agent B wins or draws against agent C on 71.1% of the games and agent C wins or draws against agent A on 65.3% of the matches. We show recordings of example tournament matches between agent A, B and C to demonstrate qualitatively the diversity in their policies (video 3 on the website2 ). Elo rating alone would yield a different picture: agent B is the best agent in the tournament with an Elo rating of 1084.27, followed by C at 1068.85; Agent A ranks 5th at 1016.48 and we would have incorrectly concluded that agent B ought to beat agent A with a win-rate of 62%. All variants of agents presented in the experimental section are evaluated against the set of 3 agents in terms of their pair-wise expected difference in score, weighted by support weights.

5. RESULTS:

We describe in this section a set of experimental results. We first present the incremental effect of various algorithmic components. We further show that population-based training with co-play and reward shaping induces a progression from random to simple ball chasing and finally coordinated behaviors. A tournament between all trained agents is provided in Appendix D.

5.1. ABLATION STUDY:

We incrementally introduce algorithmic components and show the effect of each by evaluating them against the set of 3 evaluation agents. We compare agent performance using expected goal difference weighted according to the Nash averaging procedure. We annotate a number of algorithmic components as follows: ff: feedforward policy and action-value estimator; evo: population-based training with agents evolving within the population; rwd shp: providing dense shaping rewards on top of sparse environment scoring/conceding rewards; lstm: recurrent policy with recurrent action-value estimator; lstm q: feedforward policy with recurrent action-value estimator; channels: decomposed action-value estimation for each reward component; each with its own, individually evolving discount factor.

Population-based Training with Evolution::

We first introduce PBT with evolution. Figure 3 (ff vs ff + evo) shows that Evolution kicks in at 2B steps, which quickly improves agent performance at the population level. We show in Figure 4 that Population-based training coupled with evolution yields a natural progression of learning rates, entropy costs as well as the discount factor. Critic learning rate gradually decreases as training progresses, while discount factor increases over time, focusing increasingly on long-term return. Entropy costs slowly decreases which reflects a shift from exploration to exploitation over the course training.

Reward Shaping: We introduced two simple dense shaping rewards in addition to the sparse scoring and conceding environment rewards: vel-to-ball: player's linear velocity projected onto its unit direction vector towards the ball, thresholded at zero; vel-ball-to-goal: ball's linear velocity projected onto its unit direction vector towards the center of opponent's goal. Furthermore the sparse goal reward and concede penalty are separately evolved, and so can receive separate weight that trades off between the importance of scoring versus conceding. Dense shaping rewards make learning significantly easier early in training. This is reflected by agents' performance against the dummy evaluator where agents with dense shaping rewards quickly start to win games from the start (Figure 3 , ff + evo vs ff + evo + rwd shp). On the other hand, shaping rewards tend to induce sub-optimal policies (Ng et al., 1999; Popov et al., 2017) ; We show in Figure 5 however that this is mitigated by coupling training with hyper-parameter evolution which adaptively adjusts the importance of shaping rewards. Early on in the training, the population as a whole decreases the penalty of conceding a goal which evolves towards zero, assigning this reward relatively lower weight than scoring. This trend is subsequently reversed towards the end of training, where the agents evolved to pay more attention to conceding goals: i.e. agents first learn to optimize scoring and then incorporate defending. The dense shaping reward vel-to-ball however quickly decreases in relative importance which is mirrored in their changing behavior, see Section 5.2.

Recurrence: The introduction of recurrence in the action-value function has a significant impact on agents' performance as shown in Figure 3 (ff + evo + rwd shp vs lstm + evo + rwd shp reaching weighted expected goal difference of 0 at 22B vs 35B steps). A recurrent policy seems to underperform its feedforward counterpart in the presence of a recurrent action-value function. This could be due to out-of-sample evaluators which suggests that recurrent policy might overfit to the behaviors of agents from its own population while feedforward policy cannot.

Decomposed Action-Value Function: While we observed empirically that the discount factor increases over time during the evolution process, we hypothesize that different reward components require different discount factor. We show in Figure 6 that this is indeed the case, for sparse environment rewards and vel-ball-to-goal, the agents focus on increasingly long planning horizon. In contrast, agents quickly evolve to pay attention to short-term returns on vel-to-ball, once they learned the basic movements. Note that although this agent underperforms lstm + evo + rwd shp asymptot- ically, it achieved faster learning in comparison (reaching 0.2 at 15B vs 35B). This agent also attains the highest Elo in a tournament between all of our trained agents, see Appendix D. This indicates that the training population is less diverse than the Nash-averaging evaluation set, motivating future work on introducing diversity as part of training regime.

5.2. EMERGENT MULTI-AGENT BEHAVIORS:

Assessing cooperative behavior in soccer is difficult. We present several indicators ranging from behavior statistics, policy analysis to behavior probing and qualitative game play in order to demonstrate the level of cooperation between agents.

We provide birds-eye view videos on the website 2 (video 1), where each agent's value-function is also plotted, along with a bar plot showing the value-functions for each weighted shaping reward component. Early in the matches the 2 dense shaping rewards (rightmost channels) dominate the value, until it becomes apparent that one team has an advantage at which point all agent's value functions become dominated by the sparse conceding/scoring reward (first and second channels) indicating that PBT has learned a balance between sparse environment and dense shaping rewards so that positions with a clear advantage to score will be preferred. There are recurring motifs in the videos: for example, evidence that agents have learned a "cross" pass from the sideline to a teammate in the centre (see Appendix F for example traces), and frequently appear to anticipate this and change direction to receive. Another camera angle is provided on the website 2 (video 2) showing representative, consecutive games played between two fixed teams. These particular agents generally kick the ball upfield, avoiding opponents and towards teammates.

5.2.1. BEHAVIOR STATISTICS:

Statistics collected during matches are shown in Figure 7 . The vel-to-ball plot shows the agents average velocity towards the ball as training progresses: early in the learning process agents quickly maximize their velocity towards the ball (optimizing their shaping reward) but gradually fixate less on simple ball chasing as they learn more useful behaviors, such as kicking the ball upfield. The teammate-spread-out shows the evolution of the spread of teammates position on the pitch. This shows the percentage of timesteps where the teammates are spread at least 5m apart: both agents quickly learn to hog the ball, driving this lower, but over time learn more useful behaviors which result in diverse player distributions. pass/interception shows that pass, where players from the same team consecutively kicked the ball and interception, where players from the opposing teams kicked the ball in sequence, both remain flat throughout training. To pass is the more difficult behavior as it requires two teammates to coordinate whereas interception only requires one of the two opponents to position correctly. pass/interception-10m logs pass/interception events over more than 10m, and here we see a dramatic increase in pass-10m while interception-10m remains flat, i.e. long range passes become increasingly common over the course of training, reaching equal frequency as long-range interception.

5.2.2. COUNTERFACTUAL POLICY DIVERGENCE:

In addition to analyzing behavior statistics, we could ask the following: "had a subset of the observation been different, how much would I have changed my policy?". This reveals the extent to which an agent's policy is dependent on this subset of the observation space. To quantify this, we analyze counterfactual policy divergence: at each step, we replace a subset of the observation with 10 valid alternatives, drawn from a fixed distribution, and we measure the KL divergence incurred in agents' policy distributions. This cannot be measured for a recurrent policy due to recurrent states and we investigate ff + evo + rwd shp instead (Figure 3 ), where the policy network is feedforward. We study the effect of five types of counterfactual information over the course of training.

ball-position has a strong impact on agent's policy distribution, more so than player and opponent positions. Interestingly, ball-position initially reaches its peak quickly while divergence incurred by counterfactual player/opponent positions plateau until reaching 5B training steps. This phase coincides with agent's greedy optimization of shaping rewards, as reflected in Figure 8 . Counterfactual teammate/opponent position increasingly affect agents' policies from 5B steps, as they spread out more and run less directly towards the ball. Opponent-0/1-position incur less divergence than teammate position individually, suggesting that teammate position has relatively large impact than any single opponent, and increasingly so during 5B-20B steps. This suggests that comparatively players learn to leverage a coordinating teammate first, before paying attention to competing opponents. The gap between teammate-position and opponents-position eventually widens, as opponents become increasingly relevant to the game dynamics. The progression observed in counterfactual policy divergence provides evidence for emergent cooperative behaviors among the players.

5.2.3. MULTI-AGENT BEHAVIOR PROBING:

Qualitatively, we could ask the following question: would agents coordinate in scenarios where it's clearly advantageous to do so? To this end, we designed a probe task, to test our trained agents for coordination, where blue0 possesses the ball, while the two opponents are centered on the pitch in front. A teammate blue1 is introduced to either left or right side. In Figure 9 we show typical traces of agents' behaviors (additional probe task video shown at Video 4 on our website 2 ): at 5B steps, when agents play more individualistically, we observe that blue0 always tries to dribble the ball by itself, regardless of the position of blue1. Later on in the training, blue0 actively seeks to pass and its behavior is driven by the configuration of its teammate, showing a high-level of coordination. In "8e10 left" in particular, we observe two consecutive pass (blue0 to blue1 and back), in the spirit of 2-on-1 passes that emerge frequently in human soccer games.

6. RELATED WORK:

The population-based training we use here was introduced by Jaderberg et al. ( 2018) for the capturethe-flag domain, whereas our implementation is for continuous control in simulated physics which is less visually rich but arguably more open-ended, with potential for sophisticated behaviors generally and allows us to focus on complex multi-agent interactions, which may often be physically observable and interpretable (as is the case with passing in soccer). Other recent related approaches to multi-agent training include PSRO (Lanctot et al., 2017) and NFSP (Heinrich & Silver, 2016) , which are motivated by game-theoretic methods (fictitious play and double oracle) for solving matrix games, aiming for some robustness by playing previous best response policies, rather than the (more data efficient and parallelizable) approach of playing against simultaneous learning agents in a population. The RoboCup competition is a grand challenge in AI and some top-performing teams have used elements of reinforcement learning (Riedmiller et al., 2009; MacAlpine & Stone, 2018) , but are not end-to-end RL. Our environment is intended as a research platform, and easily extendable along several lines of complexity: complex bodies; more agents; multi-task, transfer and continual learning. Coordination and cooperation has been studied recently in deepRL in, for example, Lowe et al. (2017); Foerster et al. (2018; 2016) ; Sukhbaatar et al. (2016) ; Mordatch & Abbeel (2018) , but all of these require some degree of centralization. Agents in our framework perform fully independent asynchronous learning yet demonstrate evidence of complex coordinated behaviors. Bansal et al. (2017) ; Al-Shedivat et al. ( 2017) introduce a MuJoCo Sumo domain with similar motivation to ours, and observe emergent complexity from competition, in a 1v1 domain. We are explicitly interested in cooperation within teams as well as competition. Other attempts at optimizing rewards for multi-agent teams include Liu et al. (2012) .

A OFF-POLICY SVG0 ALGORITHM:

A.1 POLICY UPDATES

The Stochastic Value Gradients (SVG0) algorithm used throughout this work is a special case of the family of policy gradient algorithms provided by Heess et al. (2015b) in which the gradient of a value function used to compute the policy gradient, and is closely related to the Deterministic Policy Gradient algorithm (DPG) (Silver et al., 2014) , which is itself a special case of SVG0. For clarity we provide the specific derivation of SVG0 here.

Using the reparametrization method of Heess et al. (2015b) we write a stochastic policy π θ (•|s) as a deterministic policy µ θ : S × R → A further conditioned on a random variable η ∈ R p , so that a ∼ π θ (•|s) is equivalent to a ∼ µ θ (s, η), where η ∼ ρ for some distribution ρ. Then,

Q π θ (s, a) = r(s, a) + γE s ∼P (•|s,a) E a ∼π(•|s ) [Q π θ (s , a )] = r(s, a) + γE s ∼P (•|s,a) [E η ∼ρ [Q π θ (s , µ θ (s , η ))]] ∂Q π θ (s, a) ∂θ = γE s ∼P (•|s,a) E η ∼ρ ∂ ∂θ Q π θ (s , µ θ (s , η )) = γE s ∼P (•|s,a) E η ∼ρ ∂ ∂θ Q π θ (s , a ) a =µ θ (s ,η ) + ∂ ∂a Q π θ (s , a ) a =µ θ (s ,η ) ∂ ∂θ µ θ (s , η )

from which we obtain a recursion for ∂Q π θ (s,a)

∂θ:

. Expanding the recursion we obtain the policy gradient

∂Q π θ (s 0 , a 0 ) ∂θ = ∞ t=1 γ t E st∼P (•|st-1,at-1) E ηt∼ρ ∂ ∂a t Q π θ (s t , a t ) at=µ θ (st,ηt) × ∂ ∂θ µ θ (s t , η t ) s 0 , a 0 , a τ = µ θ (s τ , η τ ), η τ ∼ ρ∀τ < t = S R p ζ(s, η) ∂ ∂a Q π θ (s, a) a=µ θ (s,η) ∂ ∂θ µ θ (s, η)dηds

where ζ(s, η) := ∞ t=1 γ t p t (s, η) and where p t (s, η) is the joint density over (state, η) at timestep t following the policy. Typically γ is replaced with 1 in the definition of ζ to avoid discounting terms depending on future states in the gradient too severely. This suggests Algorithm 3 given in Heess et al. (2015b) . For details on recurrent policies see Heess et al. (2015a) .

Algorithm 2 Off-policy SVG0 algorithm (Heess et al., 2015b As in Section 3.1, in any given game, by treating all other players as part of the environment dynamics, we can define action-value function for policy π θ controlling player i:

Q π θ ,i (s, a; π \i ) := E H t=0 γ t r i t s 0 = s, a i 0 = a; π i = π θ , π \i

In our soccer environment the reward is invariant over player and we can drop the dependence on i.

SVG requires the critic to learn a differentiable Q-function. The true state of the game s and the identity of other agents π \i , are not revealed during a game and so identities must be inferred from their behavior, for example. Further, as noted in Foerster et al. (2017) , off-policy replay is not always fully sound in multi-agent environments since the effective dynamics from any single agent's perspective changes as the other agent's policies change. Because of this, we generally model Q as a function of an agents history of observations -typically keeping a low dimensional summary in the internal state of an LSTM: Q π θ (•, •; ψ) : X × A → R, where X denotes the space of possible histories or internal memory state, parameterized by a neural network with weights ψ. This enables the Q-function to implicitly condition on other players observed behavior and generalize over the diversity of players in the population and diversity of behaviors in replay, Q is learned using trajectory data stored in an experience replay buffer B, by minimizing the k-step return TD-error with off-policy retrace correction (Munos et al., 2016) , using a separate target network for bootstrapping, as is also described in Hausman et al. (2018) ; Riedmiller et al. (2018) . Specifically we minimize:

L(ψ) := E ξ∼B (Q π θ (x i , a i ; ψ) -Q retrace (ξ)) 2

where ξ := ((s t , a t , r t )) i+k t=i is a k-step trajectory snippet, where i denotes the timestep of the first state in the snippet, sampled uniformly from the replay buffer B of prior experience, and Q retrace is the off-policy corrected retrace target:

Q retrace (ξ) := Q(x i , a i ; ψ) + k t=0 γ t t+i s=i+1 c s r(s i+t , a i+t )+ γE a∼π(•|xi+t+1) [ Q(x i+t+1 , a; ψ)] -Q(x i+t , a i+t ; ψ)

where, for stability, Q(•, •; ψ) : X ×A → R and π are target network and policies (Mnih et al., 2015) periodically synced with the online action-value critic and policy (in our experiments we sync after every 100 gradient steps), and c s := min(1, π(as|xs) β(as|xs) ), where β denotes the behavior policy which generated the trajectory snippet ξ sampled from B, and i s=i+1 c s := 1. In our soccer experiments k = 40. Though we use off-policy corrections, the replay buffer has a threshold, to ensure that data is relatively recent.

When modelling Q using an LSTM the agent's internal memory state at the first timestep of the snippet is stored in replay, along with the trajectory data. When replaying the experience the LSTM is primed with this stored internal state but then updates its own state during replay of the snippet. LSTMs are optimized using backpropagation through time with unrolls truncated to length 40 in our experiments.

B POPULATION-BASED TRAINING PROCEDURE B.1 FITNESS:

We use Elo rating (Elo (1978) ), introduced to evaluate the strength of human chess players, to measure an agent's performance within the population of learning agents and determine eligibility for evolution. Elo is updated from pairwise match results and can be used to predict expected win rates against the other members of the population.

For a given pair of agents i, j (or a pair of agent teams), s elo estimates the expected win rate of agent i playing against agent j. We show in Algorithm 3 the update rule for a two player competitive game for simplicity, for a team of multiple players, we use their average Elo score instead. By using Elo as the fitness function, driving the evolution of the population's hyperparamters, the agents' internal hyperparameters (see Section 3.3) can be automatically optimized for the objective we are ultimately interested in -the win rate against other agents. Individual shaping rewards would otherwise be difficult to handcraft without biasing this objective.

Published as a conference paper at ICLR 2019 Algorithm 3 Iterative Elo rating update. 1: Initialize rating r i for each agent in the agent population. 2: K: step size of Elo rating update given one match result. 3: s i , s j : score for agent i, j in a given match. 4: procedure UPDATERATING(r i , r j , s i , s j ) 5:

s ← (sign(s i -s j ) + 1)/2 6: s elo ← 1/(1 + 10 (rj -ri)/400 ) 7:

r i ← r i + K(s -s elo ) 8: r j ← r j -K(s -s elo ) 9: end procedure B.2 EVOLUTION ELIGIBILITY

To limit the frequency of evolution and prevent premature convergence of the population, we adopted the same eligibility criteria introduced in Jaderberg et al. (2017) . In particular, we consider an agent i eligible for evolution if it has:

1. processed 2 × 10 9 frames for learning since the beginning of training; and 2. processed 4 × 10 8 frames for learning since the last time it became eligible for evolution. and agent j can be a parent if agent j has 1. processed 4 × 10 8 frames for learning since it last evolved. which we refer to as a "burn-in" period.

B.3 SELECTION:

When an agent i becomes eligible for evolution, it is compared against another agent j who has finished its "burn-in" period for evolution selection. We describe this procedure in Algorithm 4.

Algorithm 4 Given agent i, select an agent j to evolve to. 1: T select : win rate selection threshold below which A i should evolve to A j . 2: r i , r j : Elo ratings of agents i, j. Upon selection for evolution, agent i inherits hyperparameters from agent j by "cross-over" meaning that hyperparameters are either inherited or not independently with probability 0.5 as described in Algorithm 5: B.5 MUTATION Upon each evolution action the child agent mutates its hyper-parameters with mutation probability p mutate at a multiplicative perturbation scale p perturb . In this work, we apply a mutation probability of p mutate = 0.1 and p perturb = 0.2 for all experiments. We limit a subset of hyperparameters to bounded ranges (e.g. discount factor) such that their values remain valid throughout training.

Published as a conference paper at ICLR 2019 Algorithm 5 Agent i inherits from agent j by cross-over.

1: Agent i, j with respective network parameters θ i , θ j and hyper-parameters θ h i , θ h j . 2: procedure INHERIT(θ i , θ j , θ h i , θ h j )

3: We parametrize each agent's policy and critic using neural networks. Observation preprocessing is first applied to each raw teammate and opponent feature using a shared 2-layer network with 32 and 16 neurons and Elu activations (Clevert et al., 2015) to embed each individual player's data into a consistent, learned 16 dimensional embedding space. The maximum, minimum and mean of each dimension is then passed as input to the remainder of the network, where it is concatenated with the ball and pitch features. This preprocessing makes the network architecture invariant to the order of teammates and opponents features.

θ i ←

Both critic and actor then apply 2 feed-forward, elu-activated, layers of size 512 and 256, followed by a final layer of 256 neurons which is either feed-forward or made recurrent using an LSTM (Hochreiter & Schmidhuber, 1997) . Weights are not shared between critic and actor networks.

We learn the parametrized gaussian policies using SVG0 as detailed in Appendix A, and the critic as described in Section A.2, with the Adam optimizer (Kingma & Ba, 2014) used to apply gradient updates.

D HEAD-TO-HEAD TOURNAMENT OF TRAINED AGENTS:

We also ran a round robin tournament with 50,000 matches between the best teams from 5 populations of agents (selected by Elo within their population), all trained for 5e10 agent steps -i.e. each learner had processed at least 5e10 frames from the replay buffer, though the number of raw environment steps would be much lower than that) and computed the Elo score. This shows the advantage of including shaping rewards, adding a recurrent critic and separate reward and discount channels, and the further (marginal) contribution of a recurrent actor. The full win rate matrix for this tournament is given in Figure 10 . Note that the agent with full recurrence and separate reward channels attains the highest Elo in this tournament, though performance against our Nash evaluators in Section 5.1 is more mixed. This highlights the possibility for non-transitivities in this domain and the practical need for robustness to opponents.

E HYPERPARAMETER EVOLUTION:

To assess the relative importance of hyperparameters we replicated a single experiment (using a feed-forward policy and critic network) with 3 different seeds, see Figure 11 . Critic learning rate and entropy regularizer evolve consistently over the three training runs. In particular the critic learning rate tends to be reduced over time. If a certain hyperparameter was not important to agent performance we would expect less consistency in its evolution across seeds, as selection would be driven by other hyperparameters: thus indicating performance is more sensitive to critic learning rate than actor learning rate.

Team Elo lstm + evo + rwd shp + channels 1071 lstm q + evo + rwd shp + channels 1069 lstm q + evo + rwd shp 1006 ff + evo + rwd shp 956 ff + evo 898

Figure 10 : Win rate matrix for the Tournament between teams: from top to bottom, ordered by Elo, ascending: ff + evo; ff + evo + rwd shp; lstm q + evo + rwd shp; lstm q + evo + rwd shp + channels; lstm + evo + rwd shp + channels. ELo derived from the tournament is given in the table. 

F BEHAVIOR VISUALIZATIONS:

As well as the videos at the website3 , we provide visualizations of traces of the agent behavior, in the repeated "cross pass" motif, see Figure 12 . 

:

https://goo.gl/AuHv7V

https://goo.gl/AuHv7V

Figures and Tables:

Figure 1: Top-down view with individual camera views of 2v2 multi-agent soccer environment.

Figure 2: L1: selected set of agents in Nash support set with their respective support weights. L2: pair-wise expected goal difference among evaluator agents. L3: Elo ratings for all agents computed from tournament matches. L4: pair-wise expected goal difference among all agents.

Figure 3: Weighted expected goal difference shown in blue line. Agents' expected goal difference against each evaluator agent in point plot. A dummy evaluator that takes random actions has been introduced to show learning progress early in the training, with zero weight in the performance computation.

Figure 4: Evolution of hyper-parameters. Hyperparameters of individual agents within the population in gray.

Figure 5: Evolution of relative importance of dense shaping rewards over the course of training. Hyperparameters of individual agents within the population in gray.

Figure 6: Evolution of discount factor for each reward component. We show hyperparameters of individual agents within the population in gray.

Figure 7: Behavior statistics evolution.

Figure 8: L1: agent's average velocity towards the ball. L2: percentage of time when players within a team are spread out. L3: KL divergence incurred by replacing a subset of state with counterfactual information.

Figure 9: L1: Comparison between two snapshots (5B vs 80B) of the same agent. L2: number of successful passes and interception occurred in the first 100 timesteps, aggregated over 100 episodes.

3: procedure SELECT(A i , {A i } i∈[1,..,N ];i =j ) 4:Choose A j uniformly at random from {A i } i∈[1,..,N ];i =j . 5:s elo ← 1/(1 + 10 (rj -ri)/400 ) 6: if s elo < T select then

Figure 11: Hyperparameter evolution for three separate seeds, displayed over three separate rows.

Figure 12: On the left red agent 0 has passed to agent 1, who apparently ran into position to receive. On the right blue agent 1 has passed to agent 0.

Algorithm 1 Population-based Training for Multi-Agent RL. 1: procedure PBT-MARL 2: {Ai} i∈[1,..,N ] N independent agents forming a population. 3: for agent Ai in {Ai} i∈[1,..,N ] do 4:Initialize agent network parameters θi and agent rating ri to fixed initial rating Rinit.

Table content: <table><tr><td>5:</td><td colspan="2">Sample initial hyper-parameter θ h i from the initial hyper-parameter distribution.</td></tr><tr><td>6:</td><td>end for</td><td/></tr><tr><td>7:</td><td>while true do</td><td/></tr><tr><td>8:</td><td colspan="2">Agents play TrainingMatches and update network parameters by Retrace-SVG0.</td></tr><tr><td>9:</td><td>for match result (si, sj) ∈ TrainingMatches do</td><td/></tr><tr><td>10:</td><td>UpdateRating(ri, rj, si, sj)</td><td>See Appendix B.1</td></tr><tr><td>11:</td><td>end for</td><td/></tr><tr><td>12:</td><td>for agent Ai ∈ {Ai} i∈[1,..,N ] do</td><td>Evolution Procedure</td></tr><tr><td>13:</td><td>if Eligible(Ai) then</td><td>See Appendix B.2</td></tr><tr><td>14:</td><td>Aj ← Select(Ai, {Ai} i∈[1,..,N ];i =j )</td><td>See Appendix B.3</td></tr><tr><td>15:</td><td>if Aj = NULL then</td><td/></tr><tr><td>16:</td><td>Inherit(θi, θj, θ h i , θ h j )</td><td>Ai inherits from Aj, See Appendix B.4</td></tr><tr><td>17:</td><td>θ h i ← Mutate(θ h i )</td><td>See Appendix B.5</td></tr><tr><td>18:</td><td>end if</td><td/></tr><tr><td>19:</td><td>end if</td><td/></tr><tr><td>20:</td><td>end for</td><td/></tr><tr><td>21:</td><td/><td/></tr></table>

).

Table content: <table><tr><td colspan="2">1: initialize replay buffer B = ∅</td><td/><td/></tr><tr><td colspan="2">2: sample initial state s 0 from environment</td><td/><td/></tr><tr><td colspan="2">3: for t do=0 to ∞ do</td><td/><td/></tr><tr><td>4:</td><td colspan="2">sample action from current policy a t = µ θ (•|s t , η), η ∼ ρ</td><td/></tr><tr><td>5: 6:</td><td colspan="2">observe reward and state observation r t , s t train Q π θ (•, •; ψ) off policy using B (see Section A.2)</td><td>Critic update.</td></tr><tr><td>7:</td><td>θ ← θ + α ∂ ∂a Q π θ (s t , a; ψ) a=µ θ (st,ηt)</td><td>∂ ∂θ µ θ (s t , η t )</td><td>Policy update.</td></tr><tr><td colspan="2">8: end for</td><td/><td/></tr><tr><td colspan="2">A.2 Q-VALUE UPDATES</td><td/><td/></tr></table>

Peer review (iclr2019):
 The paper proposes a new environment - 2vs2 soccer - to study emergence of multi-agent coordinated team behaviors. Learning relies on population-based training of agent*s shaped reward mixtures and approach of nash averaging is used for evaluation. Clarity: the paper is well-written and clear. The ablations provided are helpful in understanding how much different introduced components matter, and quantitative and qualitative analysis of resulting behavior is quite nice Originality: the individual pieces of this work (PBT, SVG, nash averaging) have been introduced previously, but this paper puts them together in a well-chosen manner. Significance: I believe this paper proposes a number of interesting observations (effects of PBT, evaluation, effects of recurrent policies to overcome non-stationarity issues) that I believe would be of value to the part of ICLR community doing research in multi-agent systems.