AGAI-L03: Intro to Multi-Agent Reinforcement Learning

In short

How does one agent learn from reward alone, and what breaks when several agents learn in the same environment? A single agent faces a Markov decision process: values obey the Bellman equations, which value iteration solves when the model is known and Q-learning approximates from samples when it is not. With several agents the problem is a stochastic game, where transitions and each agent’s reward depend on the joint action, so “maximise your return” no longer defines a solution. Learning becomes non-stationary, credit must be split between agents, learners can settle in a bad equilibrium, and joint spaces grow exponentially with the number of agents. Independent Q-learning (each agent treats the others as environment) has no guarantees and miscoordinates in the climbing game, but it scales and is the standard baseline.

No mock exam exists yet. Likely questions: why multi-agent RL is harder than single-agent RL, independent learners, and small computations (a Q-learning update, effective horizon, ε-greedy probabilities, classifying a payoff structure).

Learning from your own actions

Reinforcement Learning is sequential decision making: your actions shape what you see next. Chess and robot control qualify; time-series forecasting and speech recognition do not, because a forecast does not change future demand.

Supervised learning is open-loop: it gets a dataset of inputs with correct labels, assumed i.i.d. (independent and identically distributed), and learns . RL is closed-loop: the agent sees , picks its own , and gets back a reward and the next state. Its data is not i.i.d. (consecutive samples are correlated and depend on how it acts) and has no labels, only reward. The goal is a policy maximising .

The pieces of an RL problem

An agent interacts with an environment to achieve a goal:

  • Agent: a policy , the probability of action in state , with parameters .
  • Environment: an MDP (Markov Decision Process): states, actions, transitions and rewards .
  • Goal: maximise return, , estimated by averaging sampled runs ( is the reward at step of run ).

Algorithms loop: run the policy to generate samples, estimate the return (or fit a model), improve the policy.

The running example: Spot, a robot dog in a 4×4 grid, starts top-left; home (bottom-right) is worth +1, four holes −1; actions up, right, down, left.

 S  .  .  .        S = start
 .  X  .  X        X = hole (-1)
 .  .  .  X        H = home (+1)
 X  .  .  H

Markov property

The state is a complete summary of the past, as far as the future is concerned: knowing earlier states and actions does not change .

If Spot has a battery the state leaves out, the same cell can lead to different futures depending on how long Spot has walked, so the cell is no longer Markov (partial observation is the topic of POMDPs).

Solving an MDP means finding a policy that maximises the expected discounted return

where the Discount Factor makes a reward steps ahead count as much as one now. (The RL course writes this step’s reward as .) This is the single-agent solution concept, the criterion for what counts as a solution. An optimal policy always exists: best from every starting state, expressible as a deterministic map from state to action, possibly several of them, all with the same maximum return.

Values and the Bellman equations

Spot has deterministic policies (), too many to search. The Markov property helps: the future depends only on the current state, so “go right” next to home is optimal whatever happens elsewhere, and decisions can be built state by state from values.

State and action values ( Value Function)

is the expected discounted return from under ; the same after first taking . Both are specific to a policy. They relate by and, for the optimal policy, .

“A state is only as good as where it leads”: values satisfy the self-consistency conditions called the Bellman equations, and they are correct when these hold in every state.

Bellman equations for a policy

  • : probability the policy picks ; : step reward; : discount
  • : probability of landing in ; , : value of where you land

Turn into , apply to every state from any initial guess, and repeat until the values stop changing: that evaluates . Now make the policy greedy, , and the average over actions becomes a max:

Value iteration

This chases a moving target, since the evaluated policy improves after every update; when the values stop changing, the policy is optimal (Value Iteration, a Dynamic Programming method for the Bellman Optimality Equation).

Learning without a model: Q-learning

Dynamic programming needs and . That model is often unavailable or intractable (Breakout has a bazillion states); usually there is only a simulator to sample. The RL problem: no prior information on and , only experience , learned one transition at a time. So replace the model with samples: the expectation becomes one observed transition, and with a greedy target this gives Q-Learning.

Q-learning update

  • : one observed transition; : learning rate
  • : the target, a one-sample estimate of assuming the best action next
  • the bracket is the TD error; if is terminal there is no future value and the target is just

Dynamic programming makes a full pass (every state, action and outcome, weighted by probability); Q-learning uses a single sample, so its target is noisy and averages the noise out over visits. The max makes it learn the greedy policy’s values while acting exploratorily (Temporal Difference Learning). The full loop (choose ε-greedily, act, update, decay ε) is the independent Q-learning pseudocode further down, run with one agent.

One update by hand

; Spot moves down, gets , and . With , : target , TD error , new .

Sampling brings new challenges: exploration (you only learn about states you visit), noise and credit assignment (biased, high-variance updates; late rewards must be traced to their causes) and data efficiency (samples can be expensive). Value iteration is simple and fast but needs a model; Q-learning needs no prior knowledge but must explore and is slow.

Discount, learning rate and exploration

Discount factor. sets the present value of future rewards: eat the cupcake now, or invest for a bigger payoff in five years.

Effective horizon

roughly how many steps ahead the agent looks: gives 10, gives 100. The weights sum to , so a reward of 1 per step is worth undiscounted steps.

It is usually set high (0.99), and it is needed mainly for infinite-horizon tasks, where it keeps the sum finite. It also shapes the solution: in an apple orchard whose regrowth depends on how many apples are left, a low picks everything now and nothing regrows, while a high leaves apples to keep the orchard producing. (Outside the course material: a low suits tasks where only the near future matters, and short horizons are quicker to learn.)

Learning rate. sets how much a new sample is trusted against current belief; the update is a running average:

In a deterministic environment a high is fast and fine, a low one slow and wasteful. In a stochastic one (a slippery ice grid where moves sometimes slide) a high is noisy and never settles, a low one smooth and accurate but slow. The fix is to decay .

Exploration. If you never try things, you never discover they are better. An agent that keeps refining its first path to a +2 goal never finds the +5 goal further away. Too little exploration sticks with the suboptimal, too much wastes samples (Exploration vs Exploitation), so exploration also follows a decay schedule.

ε-greedy and Boltzmann exploration

  • : probability of a uniformly random action, which can also be the greedy one (hence its extra )
  • : number of actions; : temperature, low is nearly greedy, high nearly uniform

ε-greedy is simple and easy to decay, but its exploration is blind: a disastrous action is tried as often as a nearly-best one. Boltzmann (softmax) exploration is value-aware but hard to tweak, since a good depends on the scale of the Q-values.

Exploration probabilities

Four actions, : greedy action , each other . Boltzmann with : the better action gets at and at .

Tuning is “part science, part wizardry”, since good values depend on the environment, rewards and noise: always run multiple seeds (results vary a lot between them), look at reward curves, change one parameter at a time, watch the agent act.

Many learners in one environment

In multi-agent RL (MARL), agents interact in a shared environment to achieve their own goals. Each agent has its own policy ; transitions and rewards depend on the joint action (everyone’s actions together); goals need not be aligned. Examples: chefs sharing a kitchen (Overcooked), hide and seek, rock-paper-scissors. It is a Multi-Agent System whose agents learn.

MARL is a family of problems that differ in:

  • who the agents are: how many (2, 10, thousands); shared, opposed or mixed rewards;
  • who I will face: my training opponents or new ones; control of all agents or one among many; shared learning rules or not;
  • what they can do together: communicate freely, with limited bandwidth or not at all; observe everything or part of the world;
  • the structure of the game: simultaneous or turn-based; one shot or repeated; symmetric or heterogeneous roles.

Payoff structure decides what a good solution is

The relation between the agents’ rewards shapes what a good solution means, what can go wrong and which algorithms make sense.

Fully cooperativeGeneral-sumZero-sum
Rewardsanything in between
In wordswe all want the same thingwe each have our own preferencesyour win is my loss
Exampleswarehouse robots, Overcookedtraffic at an intersectionhide and seek, rock-paper-scissors
Learning mustcoordinate how to split tasksalso balance individual and group welfarestay robust to many opponents

General-sum learners struggle with Pareto inefficiency, outcomes where everyone could be better off, like mutual defection in the Prisoner’s Dilemma (Pareto Optimality, Social Dilemma). In zero-sum games my changes prompt my opponent’s counter-changes. To classify a game, check every cell: equal payoffs everywhere is fully cooperative, payoffs summing to zero everywhere is zero-sum, anything else general-sum. The Prisoner’s Dilemma (3,3 / 0,5 / 5,0 / 1,1) is general-sum: the sums 6, 5, 5, 2 are not zero.

Stochastic games: the MDP with many agents

Stochastic game

The multi-agent generalisation of an MDP: agents act simultaneously and each has its own reward. A Stochastic Game is the tuple :

  • : the agents; : the shared state space; : agent ‘s actions
  • : transitions, depending on the joint action
  • : agent ‘s own reward function; : discount

Lecture 2 writes the same object as , with transitions and an initial-state distribution ; here the transitions are and the discount is part of the tuple.

The iterated Prisoner's Dilemma

; the state is last round’s actions of both players, ; ; the joint action fixes the next state (play C and D, next state CD); rewards come from the PD matrix (3 each for mutual cooperation, 5 and 0 when one defects on a cooperator, 1 each for mutual defection). A policy can react to the state: “cooperate if the other cooperated last time”. A one-shot normal-form game is the single-state case.

Agent 's objective

Agent ‘s expected discounted return ( is its reward at step ) depends on everyone else’s policy too, but agent controls only its own .

In an MDP the solution concept was “maximise your return”. That is no longer expressive enough: my best policy depends on yours and yours on mine. MARL optimises instead for stability (a Nash Equilibrium: no agent gains by changing only its own policy, each policy a Best Response to the others), no regret (outside the course material: in hindsight no single fixed action would have done better), social welfare (total reward) or robustness to opponents.

What convergence means when everyone learns

In an MDP, learning has converged when the policy stops changing. In matching pennies, a penalty kick, each player picks heads (H) or tails (T); the goalkeeper (row) wins if they match, the kicker (column) if they differ.

HT
H1, −1−1, 1
T−1, 11, −1

If the goalkeeper leans to H, the kicker should lean to T, so the goalkeeper should switch to T, and so on. Any change I make gives my partner a reason for the opposite change, so the learning dynamics orbit around the equilibrium (each plays H with probability 0.5) without settling. Yet on average the cycling policies play each action half the time and earn the equilibrium’s reward (0 each). Whether that counts as converged depends on the notion: exact policy (no), average policy over many episodes (yes), average reward of the optimal policy (yes). Stochastic games challenge both MDP notions, optimality and convergence.

Why multi-agent learning is hard

Non-stationarity and credit assignment limit how well we can learn, since both make the signal very noisy. Equilibrium selection decides where we end up: there are many equilibria, and the desirable ones are often harder to reach. Scalability makes all of them worse.

Non-stationarity: experience has a shelf life

To agent the other agents are part of the environment, which therefore changes when they do:

The environment as agent experiences it

  • : the actions of all agents except , summed over every combination
  • : probability the others play that combination
  • : the game’s true, fixed transition function

changes whenever (the others’ policies) changes, and so does agent ‘s expected reward.

In single-agent RL, targets move only because my estimates improve; in MARL they also move because the opponents’ policies change. Experience has a shelf life: targets we bootstrap from (build new estimates on) go stale. Consequences:

  • Cycling: best responses chase each other, as in matching pennies; both keep improving, neither converges.
  • Broken guarantees: MDP convergence proofs, such as Q-learning’s, assume a fixed environment.
  • Noisy targets: bootstrapping from stale estimates gives a low signal-to-noise ratio.

In practice (robot football, say) it is a moving signal that is hard to track, the non-stationarity Lecture 1 flagged.

Credit assignment: whose action earned the reward

Single-agent RL has temporal credit assignment: which earlier action led to this reward? MARL adds a new axis, agent credit: whose action led to it? See Multi-Agent Credit Assignment.

The lazy agent in level-based foraging

Agents on a grid collect apples (outside the course material: an apple can be loaded only if the agents loading it have enough combined level). Agents A, B and C share a team reward of +1 per apple. A and B do the work while C wanders in a corner, yet C also receives +1, so whatever it was doing is reinforced: a lazy agent gets its behaviour reinforced because a teammate succeeded.

Disentangling contributions needs counterfactuals (what if C had acted differently?), so many samples and brutal exploration: a new layer on an already hard causal inference problem, at very low signal-to-noise. It is worst in fully cooperative games, where there is no individual signal at all, but also present in general-sum games, where individual rewards still depend on the others.

Fishing from a shared lake

Agents compete for fish, but the lake can be depleted (a Social Dilemma). Wrong lesson from a good outcome: I fish aggressively while the others hold back and catch lots, so aggression looks good, though it paid only because they held back. Wrong lesson from a bad outcome: I fish sustainably, the others hold back too, I catch little, so sustainability looks bad, though that shared restraint is what keeps the lake stocked. (The course has the others holding back in both cases. The second is cleaner with the others fishing aggressively: they cause my small catch, and I blame my own restraint.)

Equilibrium selection: settling in the wrong equilibrium

This one is native to multi-agent settings and inescapable: even perfect learners can converge to suboptimal equilibria. The cause is the game itself, which has several equilibria, so better learning does not remove it. Humans do it all the time: corrupt government persists where playing along pays as long as everyone else plays along.

  • Path dependence: history and initial conditions shape the solution.
  • Reachability: some equilibria exist but are not reachable. Driving on the left and on the right are both equilibria; a country keeps the one its history gave it, since the first driver to switch crashes. Each European country likewise settles on whichever messaging app its people’s contacts use (WhatsApp, Facebook Messenger or Viber).

Learners tend to converge to “safe” equilibria, not necessarily optimal ones, because costly exploration mistakes dissuade agents. In a gridworld Stag Hunt, a hunter collects a plant alone for +1 or the stag together for +5; one who tries for the stag while the other takes plants gets nothing, so both learn plants are safe. It is a very tough exploration problem, outcomes are hard to predict, and complexity grows with the number of agents.

Scalability: the curse of dimensionality

Joint spaces grow exponentially. In an 8×8 grid with 5 actions per agent, agents have

Four agents give joint states and joint actions; ten give about and . And every other issue gets worse: more policies chasing each other (more factors in the product over ), harder credit assignment, equilibria harder to escape.

Independent learning: treat everyone else as environment

Naive MARL methods reuse single-agent RL, either centralized (one learner chooses the joint action, as if one agent controlled all) or decentralized (each agent learns alone). Multi-agent-aware methods (joint action learning, agent modelling, extensions of IGA (infinitesimal gradient ascent), no-regret learning) are in the Albrecht book. The course covers only the decentralized independent Q-learning (IQL).

Independent learning

Each agent runs regular Q-learning on its own actions and rewards and treats the other agents as part of the environment. Their changing behaviour is absorbed into the rewards and transitions it experiences, so its MDP is not fixed: . See Independent Learning.

Algorithm: Independent Q-Learning (N agents, tabular)
─────────────────────────────────────────────────────
Input: learning rate α ∈ (0,1], discount γ ∈ [0,1), exploration rate ε, N agents
Initialize for each agent i:
  Q^i(s, a^i) ← 0 for all s ∈ S, a^i ∈ A^i     // own actions only, no joint actions
 
Loop for each episode:
  s ← initial state
  Loop until s is terminal:
    For each agent i (all choose at the same time):
      With probability ε: a^i ← random action in A^i     // explore
      Otherwise:          a^i ← argmax_b Q^i(s, b)        // exploit
    Execute the joint action (a^1, ..., a^N)
    Observe next state s' and rewards r^1, ..., r^N  // fully cooperative: all r^i equal
    For each agent i:
      If s' is terminal: target^i ← r^i               // no future value
      Else:              target^i ← r^i + γ · max_b Q^i(s', b)
      Q^i(s, a^i) ← Q^i(s, a^i) + α · (target^i − Q^i(s, a^i))
                      // the others' actions never appear: they act like noise
    s ← s'
  Decay ε (and α) according to the schedule
Output: greedy policy π^i(s) = argmax_b Q^i(s, b) for each agent

With this is ordinary tabular Q-learning.

The update is plain Q-learning; what changes is what it estimates. In a one-state game with shared reward , agent A’s value averages over its partner B’s actions:

with how often B currently plays . A good joint action looks bad to A if B rarely plays its half.

IQL in the climbing game

The climbing game is fully cooperative (shared reward):

B: aB: bB: c
A: a11−300
A: b−3076
A: c005

(a, a) = 11 is the Pareto-optimal Nash equilibrium, (b, b) = 7 a suboptimal one. A centralized Q-learner with one value per joint action finds 11 quickly. Independent Q-learners get stuck at (c, c) = 5; (a, a) is unreachable for them.

Why independent learners end at (c, c)

Early on B explores roughly uniformly, so , , . c looks best because it never risks −30, and by symmetry both agents drift to it. The −30 dissuades exploring: a pays 11 only if the partner also plays a. They are stuck at minimax: the action whose worst case is best (0 for c, −30 for the others; game theory calls this the maximin action).

Outside the course material: (c, c) is not even an equilibrium, since with B on c, A would get 6 from b. Exploration hides this: B’s occasional random a costs b −30. With B greedy on c and , B plays c with probability and a, b with each, so , below .

With very low, decaying exploration the independent learners average about 5.5 and the spread across runs widens to roughly 4 to 7, which reads as some runs reaching (b, b) = 7 and others staying at (c, c) = 5: a non-stationary outcome that changes from run to run. The centralized learner sits at (b, b) for a while, then still reaches 11.

IQL in the stag hunt and in level-based foraging

In the gridworld stag hunt, centralized Q-learning approaches the stag’s value; the independent learners stay at the plant level for a long time, then improve slowly and only partly, with a large spread across seeds.

In level-based foraging with two agents starting in opposite corners, the result reverses: IQL reaches the optimal return sooner than centralized Q-learning (CQL), if more noisily. Centralized learning tracks and explores joint actions; decentralized learning . With 6 actions and 2 agents that is “one choice among 36 versus two choices among 6”. So the averaging in is a problem for coordination (it hides good joint actions, as in the climbing game) and a benefit for scalability (each agent explores a small space, which pays once the joint space blows up).

What to take from independent learning

IQL is hard to work with but not fundamentally “broken”: messy and without guarantees, it scales to large, complex environments where central learning becomes intractable. The recipe also works with IPPO (independent proximal policy optimisation), DDPG (deep deterministic policy gradient), SAC (soft actor-critic) and others, and is a widely used baseline across MARL. Tables still limit it; deep policies, which help generalisation, come next lecture (Deep Reinforcement Learning).

What to be able to write

  • RL against supervised learning; agent, MDP, return; the Markov property.
  • , , Bellman equations, value iteration and why it needs a model; the Q-learning update; challenges of sampling.
  • The effects of , and exploration, with the small computations.
  • MARL’s dimensions; the three payoff structures and classifying a game.
  • Stochastic games, the iterated PD, agent ‘s objective, the replacement solution concepts, convergence in matching pennies.
  • Non-stationarity, credit assignment, equilibrium selection, scalability.
  • Independent Q-learning: pseudocode, , the climbing game, coordination against scalability.

Model answers are in the exam questions below.

Exam questions

Flashcards