Multi-Agent RL
Reinforcement learning with several learners in one world, where each agent is part of everyone else's environment and the ground keeps shifting.
Why Does This Exist?
Single agent theory assumes a stationary world: same state, same action, same odds. Add a second learner and the assumption dies. Your rival updates overnight, so the move that scored yesterday gets punished today. Traffic, trading floors, robot fleets, and team games all live here.
Multi agent RL, building on stochastic games from Shapley (1953) and Littman (1994), studies exactly this: several policies learning at once in one shared state. The headline problem is non-stationarity, and the headline fix is centralized training with decentralized execution, CTDE. Start with Markov games for the formalism, see CTDE in action in MADDPG, and sort out reward structures in cooperative vs competitive settings.
The one idea you need first
A Markov decision process has one agent, states, actions, transition odds, and rewards. MARL keeps the shape but the transition and each reward depend on the joint action of all agents: and . Everything that follows comes from that one change.
Think of It Like This
Pickup basketball against a rival who studies you
Shooting alone in an empty gym is single agent RL: the hoop never moves. A real game adds teammates and one defender who watches film. Monday your pump fake works and you score at will. By Friday the defender stays down on every fake and blocks the same shot. Nothing about your legs changed; the environment, meaning the other learner, changed.
So you stop drilling one move and start reading the defender: what do they expect, and what beats that? Teammates add the flip side: a careless pass ruins a good cut, so credit for a basket is shared. That is MARL in miniature: adapt to adapting opponents, coordinate with partners, and never trust a lesson from last week without rechecking it.
Where it stops: gym rivals learn slowly and visibly, while agents update thousands of times per second invisibly, and no referee hands out the clean team reward numbers the math assumes.
How It Actually Works
A Markov game is the tuple : agents, shared state , one action set each, joint transitions , one reward function each, discount . Three reward patterns cover most work: fully cooperative with one shared reward, zero sum with , and mixed general sum where interests partly align.
Why independent learning wobbles
Agent maximizes , but moves with everyone else's actions. From agent 's seat the world looks non-stationary: identical local histories lead to different rewards on different days because a partner explored or a rival adapted. The Markov property fails from each agent's local view, and single agent convergence proofs fail with it. Independent Q-learning runs one learner per agent anyway and often oscillates or collapses, which the worked example below shows numerically.
The CTDE fix
Centralized training with decentralized execution splits the problem across time. In training, each agent gets a centralized critic that sees the global state plus every agent's action, which removes the ambiguity about who caused what. In MADDPG (Lowe and colleagues, 2017), each actor still maps only its own local observation to its action. At deployment the critics are deleted and actors run on local views alone. Training is stable because the critic conditions on the joint action; execution is practical because actors need no radio link to each other.
Worked example
Two partners each pick A or B. Team payoffs: , , anything mixed pays . Discount , terminal next state so value math is just the reward.
A centralized critic tracks . Both agents play A, the team banks , and with critic step size :
Now the independent learner, which sees only its own move. Suppose the partner explores B half the time. Then the expected payoff of playing A is , exactly equal to the safe from always playing B. The independent agent cannot tell a bad choice from a partner's bad day, while the centralized critic can because it conditions on both moves. The diagram draws this joint action and the to step.
Code
This snippet replays the worked example: the centralized critic step and the independent learner's blurred expectation.
def critic_update(q: float, reward: float, alpha: float) -> float: """One centralized critic correction toward the team reward.""" return q + alpha * (reward - q)
def independent_expectation(p_partner_a: float) -> float: """Expected payoff of playing A when the partner plays A with prob p.""" return p_partner_a * 10.0 + (1.0 - p_partner_a) * 0.0
print(f"central Q={critic_update(7.0, 10.0, 0.10):.4f}") # -> central Q=7.3000print(f"E[R|A]={independent_expectation(0.5):.4f}") # -> E[R|A]=5.0000print(f"E[R|B]={5.0:.4f}") # -> E[R|B]=5.0000The critic climbs to on hard evidence, while the independent view ties to and learns nothing about which move was at fault.
Watch Out For
Treating other agents as background noise
Running independent Q-learning in a shared world looks fine for a while, then policies chase each other in cycles: A adapts to B, B adapts to the new A, and rewards swing without improving. Symptom: learning curves that oscillate or collapse late in training although single agent versions converged. Fix: condition critics on the joint action during training, the CTDE pattern, so each update sees what its partners actually did.
Self-play that forgets how it used to win
In competitive self-play each side overfits to the current rival. A counters B's trick, B drops the trick, then A drops the counter and becomes helpless against older versions of B that still use it. Symptom: win rate against the live rival climbs while win rate against last month's checkpoint falls. Fix: train against a league of past checkpoints, not just the latest weights, so old skills stay load bearing.
The Quick Version
- MARL puts several learners in one shared state, so each agent's world shifts as the others update.
- Joint transitions and per agent rewards define the Markov game; unilateral optima stop existing.
- Independent single agent algorithms wobble because one agent cannot separate its mistakes from its partners' exploration.
- CTDE steadies training with critics that see the joint action, then deploys actors on local observations only.
- Cooperative teams fight credit assignment, competitors fight cyclic forgetting, and both need the joint view to learn cleanly.