{'fraction_non_alphanumeric': 0.030835371729301016, 'fraction_numerical': 0.00533689126084056, 'mean_word_length': 4.896634615384615, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Resolving Implicit Coordination in Multi-Agent Deep Reinforcement Learning with Deep Q-Networks&Game Theory

We address two major challenges of implicit coordination in multi-agent deep reinforcement learning: non-stationarity and exponential growth of state-action space, by combining Deep-Q Networks for policy learning with Nash equilibrium for action selection. Q-values proxy as payoffs in Nash settings, and mutual best responses define joint action selection. Coordination is implicit because multiple/no Nash equilibria are resolved deterministically. We demonstrate that knowledge of game type leads to an assumption of mirrored best responses and faster convergence than Nash-Q. Specifically, the Friend-or-Foe algorithm demonstrates signs of convergence to a Set Controller which jointly chooses actions for two agents. This encouraging given the highly unstable nature of decentralized coordination over joint actions. Inspired by the dueling network architecture, which decouples the Q-function into state and advantage streams, as well as residual networks, we learn both a single and joint agent representation, and merge them via element-wise addition. This simplifies coordination by recasting it is as learning a residual function. We also draw high level comparative insights on key MADRL and game theoretic variables: competitive vs. cooperative, asynchronous vs. parallel learning, greedy versus socially optimal Nash equilibria tie breaking, and strategies for the no Nash equilibrium case. We evaluate on 3 custom environments written in Python using OpenAI Gym: a Predator Prey environment, an alternating Warehouse environment, and a Synchronization environment. Each environment requires successively more coordination to achieve positive rewards.


Introduction
A societal shift towards autonomous systems necessitates efficient, scalable, and fault-tolerant coordination among autonomous agents. While centralized command is most effective, network costs and exposure to a single source of failure favor decentralized coordination. In multi-agent deep reinforcement learning (MADRL), optimal control depends not only on the environment but on the policies of other agents. Effective control requires either implicit coordination or direct competition. Roadblocks to optimal outcomes include non-stationarity and state-action sparsity [2]. Non-stationarity encapsulates the 'moving-target' problem, in which agents must continuously co-adapt to each other's behavior. Agents are forced to negotiate a trade-off between learning stability and behavior adaptation [2]. Most MADRL algorithms require parameterizing the joint state-action space, an exponentially increasing space which with respect to each additional agent. A sparsity problem exists because the majority of state-action pairs are never visited. We address both issues: sparsity and non-stationarity, via an exhaustive search through the joint space of deep architectures (for state value estimation) and game theory (for decentralized policy control). Game theory enables implicit coordination through unilaterally enforced rules with minimal preconditions.

Related Work
Developments in deep reinforcement learning have resulted in super-human performance on simulated Atari games [10]. Mnih et al. [10] introduce a novel variant on Q-Learning which estimates q-values using a deep convolutional architecture. The success of the DQN framework has encouraged many extensions to the deep network architecture with the goal of addressing state-action sparsity and non-stationarity. Wang et al. [14] tackle the sparsity issue by decomposing the Q-function into a state value function and a state-dependent function. Their novel dueling-network architecture enables agents to distinguish between non-valuable and valuable states, in which some actions maintain a relative advantage over others. The authors obtain state of the art performance on Atari games. We implement dueling Q-networks for our multi-agent models which directly parametrize the joint action space (referred to in Section 2 as Joint-DQN models). Extensions, such as double Q-networks [13], minimize q-value over-estimation and maximize learning stability through use of a target network.
Game theoretic approaches to MADRL offer rule-based approaches to deterministically solving the problem of decentralized coordination. The research focuses on policy control and softens the over-reliance of most other literature on learning q-values. Q-values proxy as payoffs and Nash equilibria are calculated over the joint action space [5]. In Nash-Q learning, agents keep track of their own Q-function as well as other agents', and compute temporal difference (TD) targets with the assumption each agent will play its own Nash strategy [5]. General-sum stochastic games can have multiple Nash equilibria which has traditionally made the application of game theory to RL a "nondeterministic procedure" [12]. Yet in the presence of tie breaking rules, Nash-Q learning and its variants can converge to a stationary policy under restrictive and debated conditions. Shoham et al. [12] argue a centralized tie-breaking "oracle" is needed (what we deem in our experiments, a Set Controller), while Hu et al. [5] argue that Nash-Q learning will converge in the presence of a globally optimal joint action profile at each step. There is no consensus opinion, however, and convergence with Nash-Q appears to be very sensitive to game dynamics. (As such, we test on 3 environments). The Friend-or-Foe (FoF) algorithm represents a simple extension of Nash-Q: an agent designates others as friends or foes and presumes the other agents either seek to minimize (zero-sum foes), or maximize (abetting friends), its q-values [12,8]. FoF's assumption of a globally optimal joint action profile enables action selection to occur over one's own q-values without consideration of the other agent's q-values. Inspired by the correlated equilibrium concept, Greenwald et al. introduce correlated Q-learning (CQ-Learning) [3], which deliberates among equilibria (i.e., Nash) according to several rules: maximizing the sum of agents' q-values (Utilitarian), maximizing the minimum of agents' q-value (Egalitarian), and maximizing the maximum q-value (Republican).

Methodology
Our methods leverage the success of the DQN architecture [9] and extend it to a niche class of general-sum common-payoff games. These games feature multiple agents who share rewards across multi-step finite episodes. We restrict ourselves to games which can be modeled as Markov Decision Processes (MDP) with discrete state and action spaces. We only consider model free learning where the agent has full knowledge of the current state yet must formulate an experimentally driven estimate of transition probabilities.

Independent-DQN versus Joint-DQN:
We explore the two main challenges of MADRL: nonstationarity and state-action sparsity 1, through a experimental grid search of architectures and learning procedures. The primary theoretical decision relates to whether agents learn the full joint action space, or learn independently of the other agents. We have created two agent phenotypes: Independent-DQN (IDQN) and Joint-DQN (JDQN). IDQN extends the DQN algorithm directly to the multi-agent setting by treating other agents as part of the environment. For notation purposes, consider the transition tuple (φ j , a j , r j , φ j+1 ): , where φ j and φ j+1 represent the current and subsequent processed state frames, a j represents the action chosen at time j, and r j the reward at time j. Each IDQN agent i models its own TD-target for transition j as Q represents a deep network with θ i parameters. γ represents the reward discount factor. The gradient update is performed on mini-batches according to the Huber loss [6] of the TD target against the predicted q-value Q(φ j , a j ; θ). The JDQN agent learns the joint action space generated by all agents.
Formally speaking, agent i models its TD-target for transition tuple j as r j + γQ(φ j+1 , Joint(Q(φ j+1 , a, 1; θ 1 ), Q(φ j+1 , a, i; θ i ), ..., Q(φ j+1 , a, N ; θ N )); θ i ) where a represents the joint action vector, N represents the number of agents, and θ i represents the network parameters for the i th agent. The agent's unique id is passed in to the Q network since it must first transform a global state representation into its own frame of reference. The function Joint stands for any function which receives q-values for each agent, and produces a joint action vector. Above, we considered the scenario where each agent has access to the q-network parameters of the other agents. In the case where the agent has no record, either self-maintained or requested, of the other agents' network parameters, it uses its own as a proxy. The TD target for the hidden q-value case for agent i is which relies solely on a single set of network parameters θ i . We also consider a further simplification of the Nash-Q: The Friend-or-Foe algorithm [8]. The Friend (cooperative case) algorithm assumes a globally optimal joint action and hence greedily selects actions according to just its own q-values. It fully expects the other agent will greedily select the mirror image joint action profile. In theory, fully cooperative settings should have mirrored best responses which makes greedy action over the joint action space synonymous with computing a Nash equilibrium. Yet, Q-functions trained over separately generated data will not always (initially) exhibit mirrored best responses. Hence, the Friend algorithm represents a simplification to which the private Nash-Q setting should approach. Yet the Friend algorithm acts independently over the joint space and hence maintains a stabler control function. In this light, the Friend reduction is both theoretically sound and more efficient.
Policy Control: For training purposes, policy control is carried out according to separate -greedy linear decay policies for the IDQN architecture. For the JDQN architecture, action vectors are selected according to a -joint policy with linear decay. With probability , random actions are selected, and with probability 1 − , the Joint function chooses the action vector.
Asynchronous Single Network versus Parallel: To probe the non-stationarity issue, we consider two methods for maintaining DQNs. The first method, Asynchronous Single, uses a single Q-network and buffer. All agents' experience contributes to the buffer which provides sample transitions to update the network. Each agent maintains a copy of the network and asynchronously requests its parameters. The second approach, Parallel, maintains a network and buffer for each agent. Learning occurs in parallel without any experience or weight sharing.
Single Stream versus Split Stream: Inspired by the success of residual networks, we explore recasting agent interaction as learning a residual function above and beyond the single agent state value estimation. Concretely, we learn separate upscaled single agent and other agent representations. We then concatenate the representations and learn a joint embedding, which is then added elementwise to the single agent's upscaled representation. We model the archetypal residual building block: Figure 1: A skip connection building block from the seminal paper [4] Where, in our case, F (x) represents the joint embedding of the single agent state information with that of the other agent's, and x the learned single agent state representation.
Competitive versus Cooperative: We consider competitive rewards, where rewards are not shared, and cooperative, where agents receive a common payoff regardless of the triggering agent.
Game theory & Implicit Coordination: For the JDQN architecture, we consider several game theoretic approaches for joint action selection. Inspired by Nash-Q learning [2,5], we treat q-values as payoffs and compute a payoff matrix for each agent. In the two player case with two actions, the payoff matrix for state S is as follows: where θ i represents agent i's Q-network parameters, N represents the number of agents, and a j i represents the i'th action played by agent j. The best response actions for agent 1, then, represent the row-wise maximum over the first terms of each payoff matrix cell. The best response actions for agent 2 represent the column-wise maximum over the second terms of the payoff matrix cells. Nash equilibria are stable in the sense that no agent has an incentive to unilaterally deviate. Importantly, however, it does not necessarily represent the social optimum. Additionally, rules must exist for the case of multiple or no Nash equilibria. We consider two approaches for the multiple equilibria outcome. For greedy selection, each agent acts according to the Nash equilibria which maximizes its own q-value (Greedy-Tie-Break). This may or may not result in a true Nash equilibrium since agents may decide on actions from different equilibria. As the gold standard case, we consider a socially optimal scheme, where each agent acts according to the Nash equilibria with the greatest q-value sum (Max-Sum-Tie-Break). We consider control rules for the no Nash equilibrium scenario. One rule, Greedy-No-Nash, stipulates agents greedily take the action corresponding to their highest respective q-values. Another approach, Best-Sum-No-Nash, stipulates each agent treat the other agents' actions as equiprobable and choose the action corresponding to the highest average q-value.
3 Experimental Setup

Environments
We have built three custom environments using OpenAI gym's [1] python API: Predator Prey, Warehouse, and Sync. They require increasingly more advanced levels of coordination. To conserve space, we show results only for the latter 2, more advanced environments.

Predator Prey
A multi-player game of tag: predators chase prey and are rewarded when occupying the same cell as a prey. The terminal state is reached when all prey are captured. Prey are considered part of the environment and predators are the trainable agents. Predators and prey can move in any of four directions one cell at a time. Boards are represented as 2-D arrays.

Warehouse
A simulated warehouse. The warehouse is a 7x7 grid similar to the Predator Prey state representation. It has two shelves which exist in opposite corners of the board. An episode starts with a single box placed in one of the corners. A single agent must deliver the box to the center of the board in which case a positive reward is given, and a new box is placed on the shelf opposite the previous box placement. This encourages one agent to pick up and drop off a box and the other agent to wait at the other shelf, for which a box will be deposited as soon as the other agent drops off the previous box. The episode ends when n boxes have been deposited. Actions involve moving up, right, down, or left.

Sync Environment
A toy synchronization game. Two agents are situated randomly on a 5x5 grid and most arrive at opposite corners of the board in the same time step. The episode reaches terminal state when one or both of the agents reach one of the two corners (upper left or bottom right). Agents only receive positive reward if the episode ends with both corners covered. This necessitates considering the likely action of the other agent. Actions involve moving up, right, down, left, or stationary.

State Representation
All experiments are run on 2 agent variants of the above environments. Each agent receives its own location as a row-column tuple, as well as the location of the other agent. For the Warehouse environment, an additional per-agent marker relates to whether or not that agent is currently carrying a box. For the warehouse environment, since the box location is stochastic, the row and column of a box to be picked up is also provided. The state representation for the Warehouse Environment is: [row 1 , col 1 , is_carrying 1 , row 2 , col 2 , is_carrying 2 , row_box, col_box] Where subscripts denote the respective agent ids and [row_box, col_box] the grid location of the box. For the Sync Environment the state representation is simply [row 1 , col 1 , row 2 , col 2 ].

Network Architectures
We train and test on two deep linear architectures. Split Stream: The split stream architecture decouples the state representation into self location and other agent location. The locations are separately passed through a single layer MLP with sigmoid activation to for upscaling. Then, the upscaled representations are concatenated and passed through a dense layer with ReLu activation. This layer learns a joint embedding. The joint activation is then added to the self-activation, which should encourage the joint embedding to learn a residual function. The architecture is displayed in functional form as: Where s 1 and s 2 represent the grid locations of agent 1 and agent 2, respectively. W 1 , W 2 , W j , and W o are learned weight matrices and b 1 , b 2 , b j , and b o are learned bias vectors. σ represents the sigmoid operation, [; ] represents vector concatenation, and + element-wise vector addition.

TD-Targets
We mathematically define the TD-Targets for the various settings. We show functions only for agent 1 but agent 2's targets are the mirror image. Table 1: TD-Targets for I-DQN and J-DQN algorithms at timestep j. a 1 represents agent 1's selected action, a the joint action vector, θ i represents network parameters for the i th agent, N ashEq converts q-values to payoffs and returns an action vector corresponding to a Nash equilibrium.

Experimental Results
We show updates for convergence and average statistics over 1,000 episodes with random restart.

Results on 11 x 11 Warehouse Environment
We train and evaluate on the 11 × 11 Warehouse Environment for 2 agents (Section 3.1.3). The episode ends after the minimum of 100 steps and 4 boxes have been delivered.

Results for 5x5 Sync Environment
We train and evaluate on the 5 × 5 Sync Environment for 2 agents. The Sync Environment is detailed in Section 3.1.3. Implicit coordination is a sine qua non for agents to receive a positive reward of 100. Table 3 shows average statistics and convergence steps for the suite of MADRL algorithms.

Analysis
We observe that the IDQN and Set Controller setups converge well for both environments. Contrary to what we expected, IDQN converges to a slightly better reward. Yet, the Set Controller needs to learn the entire joint space for the 2 agents, so it needs more updates to give adequate coverage to each output node in the network. The Friend algorithm exhibits strong signs of learning as reflected in elevated Q-Values and nonzero rewards (for the tougher environment Sync). The Set Controller case is the gold standard for Friend since it explicitly optimizes what the Friend algorithm proxies with 2 separate Q-networks. We expect Friend's performance to continue to approach the gold standard with longer training times. Nash-Q fails to converge which we cover in more detail in Section 4.5.1.

Comparison of Asynchronous IDQN with Synchronous IDQN
We compare the asynchronous IDQN architecture with its synchronous counterpart. As explained in Section 2, the asynchronous setup maintains a single network and buffer to which both agents submit experience data, and from which both agents receive the latest weights once every 10,000 updates. We hoped this would speed up convergence by mitigating environment stochasticity and de-correlating experience data since both agents' experience is merged into a single buffer. We test using the 5 × 5 Sync environment and the IDQN variant as it maintains 2 networks and is stable.

Analysis
We were very surprised to discover that the asynchronous architecture did not converge. We did not discover any blatant reasons for this, but our principal hypothesis is as follows. The network learns twice from a single game step, for which it receives mirrored data points. We expect this confuses the network and may lead to compounding errors. It is still surprising this issue exists with a large batch size and randomized memory replay, however.

Comparison of Single Stream versus Residual Split Stream Architecture
We compare the single stream with the residual split stream architecture, outlined in Section 3.3.

Analysis
The split stream architecture did not enhance training efficiency or stability in the manner we had hoped. This is likely due to the simplified network architecture for split stream, for which we only learn a single-level joint embedding. The single stream architecture conducts early fusion, and the joint representation passes through 3 dense layers; hence, it is able to learn more complex inter-agent dependencies. For the Sync environment on which we tested, coordination is the sine qua non for positive reward. Testing on a more forgiving environment, such as Warehouse, which does not demand such nuanced coordination, might allow the split stream architecture to outperform. The residual function concept is very compelling theoretically and has proven to work [4], so we do not think these results should be viewed as damning. Future work might explore keeping the single stream network in tact and simple introducing an auxiliary skip connection for the own agent's representation -thereby only enhancing, not detracting from, the model's expressive power.

Comparison of Nash-Q Tie Breaking and No Nash Strategies
Nash-Q theoretically converges only when there is a single optimal joint action at every step [5]. Yet, Hu et al. note that this is a restrictive, unrealistic precondition and as such, rules must be put in place to consistently break ties. We test on 4 permutations of tie-breaking rules, each defined in Section 2.

Analysis
Despite some variance in results, none of the permutations showed significant signs of reward or q-value convergence. Since there is no mathematical best practice regarding tie-breaking procedures for Nash equilibria, and its impact on convergence, it was worth exploring the gamut of available options. We were hoping that the socially optimal action profile choice: Max-Sum, would be a good proxy for the Set Controller. Yet, in the sync environment, if an agent is in the middle of the board, and attempting to reach the upper left corner, either an action of 'Up' or action of 'Left' will have the same effect. In these common instances of no optimal joint action, the model struggles to converge via implicit coordination. The case turns out to be similar for the other permutations as well. We learn from these experiments that the mere existence of multiple equilibria is problematic, and that even well-designed tie-breaking rules might not be sufficient to guarantee convergence. When no Nash equilibria are present, it is even more difficult to reason a stable strategy. Our approaches were grounded in the notion that the self-interested and cooperative incentive should align for fully cooperative settings. Yet the sensitivity of policy control over a 2-D payoff matrix proves extremely unstable regardless of network configurations.

Discussion
We show that a Nash equilibrium policy control can be applied to MADRL for multi-step MDPs under a key simplifying assumption. While the Nash-Q algorithms did not show policy control stability, the Friend-Or-Foe simplification did. Over time, the Friend-Or-Foe's assumption of mirrored mutual best responses approaches, albeit slowly, a Set Controller, which explicitly selects actions for both agents. Concretely, for fully cooperative games, independent optimization of q-values over the joint action space can roughly approximate the explicit optimization of a single joint q-function given enough training time. Given the highly unstable nature of multi-agent decentralized coordination, and highly restrictive preconditions for theoretical convergence, we deem this an encouraging, albeit incomplete, accomplishment. The fact that Nash-Q did not converge is unsurprising. Hu et al. prove the convergence of Nash-Q only under "highly restrictive technical conditions", including but not limited to, the existence of a globally optimal action at every step [5]. Most environments, including ours, do not conform to this condition given that multiple actions can be optimal (with multiple equilibria). This is analogous to there not being a unique shortest path from one point to another in a grid without barriers. We experiment with a multitude of stabilizing architectures, environments, and hyperparameter settings for Nash-Q. Given that broad and deep experimentation did not give way to convergence lends credence to the difficulty of applying Nash-Q to multi-player, multi-stage games with nonsingular optimal joint actions.
We also experiment with a multitude of approaches for learning stabilization: dueling networks [14], double Q-networks [13], residual networks [4], priority experience replay [11], and asynchronous target fixing, to varying degrees of success. We demonstrate the theoretical advantages of each: double-Q -fair estimation of q-values, residual networks -coordination as residual function, prioritized experience replay -less sparse reward learning, and asynchronous target fixing -more environment stationarity from fixing weights. We show suboptimal results for the residual split stream architecture and the asynchronous model but maintain that both are theoretically well-grounded. We believe that the split stream architecture may need to learn a more robust joint embedding for complex coordination tasks and the asynchronous architecture should sample experience from a single agent to avoid generating multiple data points from a single game step.

Conclusion
We hope that our open-source code and 3 configurable multi-agent simulations will motivate future work at the fascinating intersection of Deep Q-Learning and Nash game theory. With simplifying assumptions (Friend algorithm), deep Nash models show signs of convergence and represent theoretically sound rule-based approaches for implicit coordination. Future work should focus on how to introduce stability in Nash-Q learning for multi-stage MDPs without a globally optimal action profile. Alternatively, properly identifying games phenotypes which necessitate Nash-Q Learning over simpler variants would be an appropriate first step toward a stronger theoretical grasp of when Nash-Q learning expedites coordination.

PredatorPrey Board -Instance
In the above image of 5x5 Predator Prey board, Blue represents Predators, Green represents Preys and barriers are represented by Black blocks. Each predator receives this state representation (in the form of numpy grid) in addition to its own position. Additionally, a video of the environment (of size 10x10) is rendered and can be viewed at video link. Similarly, an example of the warehouse environment can be seen at the given link.

Poster
A poster board version of the paper can be seen here.