Game theory in The Matrix – the mathematics of dueling
One of my favorite scenes in The Matrix is the subway fight scene (clip below).
Rather than run away, Neo chooses to fight Agent Smith head on. The scene begins with a duel which I find particularly interesting due to the strategies they take.
Here is a link to the video. The duel that I am going to discuss is roughly the first 30 seconds of the video.
Youtube video: The Matrix subway fight
The detail I find most interesting is the order in which the two shoot their bullets.
It appears that Neo takes the first shot, but then they mostly fire at almost the same time. This becomes clearer as Neo and Agent Smith run towards each other. When they jump in the air and approach point blank range, the clip moves into super slow motion and it is clear they fire their bullets at exactly the same time.
In the film the simultaneous firing has the beauty of symmetry and the timing was probably chosen for aesthetics.
But one can ask: does it make sense that Neo and Agent Smith fire at the same time?
At this point in the film, Agent Smith appears to be more skilled than Neo. If we were thinking about the strategy of a duel, should the more accurate shooter fire first, or should he wait?
What’s the right time to shoot in a duel?
A simple dueling game
Consider a duel between two players A and B.
For simplicity, suppose each only has one bullet. The game works as follows.
A and B start the duel at a distance t = 1 from each other. They approach each other at the same speed, and each has to decide when to shoot.
As they get closer to each other, their accuracy increases. At distance t, the player A has a chance a(t) of killing his opponent, and for player B it is b(t). Assume both players are aware of the other’s skill.
In this duel, missing your shot is very costly. If a player shoots and misses, then the other player keeps approaching until he gets to point blank range and shoots with complete accuracy.
What is the optimal strategy of this game? That is, at what point should each player shoot?
Solution: when player A should fire
The tricky part to the game is balancing when to shoot. If you fire too early, then your opponent kills you for sure. If you wait too long, then you can also get beaten if your opponent is a good shot.
We can think about when player A should fire by listing out the chance of surviving in the different possibilities of firing at point t.
- If player A fires first: Player A will survive only if he hits, which happens with chance a(t)
- If player A waits to fire: Player A survives only if player B misses, which happens with chance 1 – b(t)
Now we can reason out player A‘s strategy. Player A will want to fire first if his chance of hitting is greater than player B‘s chance of missing:
a(t) ≥ 1 – b(t)
But he must also be careful not to fire too early. He should always wait if his chance of hitting is smaller than player B’s chance of missing:
a(t) ≤ 1 – b(t)
Putting those two equations together, we can see that Player A should shoot at the time when he is at distance t* where
a(t*) = 1 – b(t*)
Or alternately written,
a(t*) + b(t*) = 1
Solution: when player B should fire
We can do the same exercise for player B. Notice the same conditions are true:
- If player B fires first: Player B will survive only if he hits, which happens with chance b(t)
- If player B waits to fire: Player B survives only if player A misses, which happens with chance 1 – a(t)
Now we can reason out player B‘s strategy. Player B will fire first, if his chance of hitting is better than his opponent’s chance of missing:
b(t) ≥ 1 – a(t)
But he must also be sure not to fire too soon. He needs to wait so long as his chance of hitting is smaller than his opponent’s chance of missing:
b(t) ≤ 1 – a(t)
Putting those two equations together, we can see that Player B should shoot at the time when he is distance t* where
b(t*) = 1 – a(t*)
Or alternately written,
a(t*) + b(t*) = 1
Solution: they fire at the same time!
From the equations, you’ll notice that both players choose to fire at the same time! There is one specific distance which is optimal for both players.
This would not be surprising if the two players had the same accuracy level. But we solved this game using the assumption their accuracy levels were different.
So why do they end up shooting at the same time?
We can reason why this must be the case. If one person chose to fire earlier than another, say 5 seconds earlier, then he would be better off waiting. His opponent is not shooting for another 5 seconds, so he might as well wait a few more seconds to get closer and increase his accuracy.
As the equations show above, the right time to shoot is just when your chance of hitting equals your opponents chance of missing. And since one person’s failure is another person’s success, this means both players choose the same time when they are a distance such that their accuracy functions sum to a probability of 1.
The Matrix duel
While Neo does fire the first bullet, the two do appear to fire shots at almost or exactly the same time as they run towards each other.
But then again, it should come as no surprise that Neo and Agent Smith play smart strategies given their superhuman abilities.
Additional reference
The theory of duels is covered in much more detail in this game theory lecture at Yale.
Lecture 16 – Backward induction: reputation and duels
The relevant part about duels–he uses two players with wet sponges–starts about 25 minutes into the video.
Share this post:
Previous post: Are Pillsbury Toaster Strudels tastier than Kellogg’s Pop Tarts – ads I overanalyze
Next post: The world’s best tortilla puzzle



