Game Theory Simulator Back
Mathematical Sciences

Game Theory Simulator

Edit payoff matrices for Prisoner's Dilemma, Stag Hunt, and Chicken Game. Find Nash equilibria automatically and watch cooperation evolve in real-time spatial evolutionary games.

Game Presets
Payoff Matrix (Row: P1, Col: P2)
P2: Cooperate (C)P2: Defect (D)
P1: Cooperate (C) / /
P1: Defect (D) / /
Evolutionary Game Settings
Grid Size30×30
Mutation Rate2%
Coop. Rate
0
Generation
Avg Payoff
Pareto Opt.

Nash Equilibrium Condition

For all players $i$ and strategies $s_i'$:
$u_i(s_i^*, s_{-i}^*) \geq u_i(s_i', s_{-i}^*)$

Replicator equation:
$\dot{x}_i = x_i(f_i - \bar{f})$
Cooperate (C)
Defect (D)
Tit-for-Tat
Win-Stay

What is Game Theory?

🧑‍🎓
What exactly is a "Nash Equilibrium"? I see the simulator highlights cells in the payoff matrix when I run it.
🎓
Basically, it's a stable state where no player can get a better payoff by changing their strategy alone. In this simulator, when you click "Find Nash," it checks every cell in the matrix. For instance, in a classic Prisoner's Dilemma, the equilibrium is where both players defect, even though cooperating would be better for both. Try changing the payoffs in the matrix above and see how the highlighted equilibrium cell shifts.
🧑‍🎓
Wait, really? So the equilibrium isn't always the "best" overall outcome? What's that "Replicator" simulation doing then?
🎓
Exactly! That's the key tension. The Replicator Dynamics simulation shows how strategies evolve over time in a population. When you hit "Simulate," each colored dot is an agent playing a strategy. More successful strategies get copied more often. Try lowering the "Mutation Rate" slider—you'll see one strategy often takes over completely. Increase it, and you get a more mixed, unpredictable population.
🧑‍🎓
So the "Update Rule" changes how they copy each other? What happens if I switch from "Imitate Best" to "Fermi Rule"?
🎓
Great question! "Imitate Best" is deterministic—agents always copy the most successful neighbor. The "Fermi Rule" adds randomness, like making a mistake or experimenting. In practice, this can allow cooperation to survive in harsh environments like the Prisoner's Dilemma. Change the rule while the simulation runs and watch if the cooperative blue dots can sustain themselves against the defecting red ones.

Physical Model & Key Equations

The core condition for a Nash Equilibrium is that each player's strategy is a "best response" to what the others are doing. No one has an incentive to unilaterally deviate.

$$u_i(s_i^*, s_{-i}^*) \geq u_i(s_i', s_{-i}^*)$$

Here, $u_i$ is the payoff for player $i$, $s_i^*$ is their equilibrium strategy, and $s_{-i}^*$ are the strategies of all other players. The inequality must hold for every possible alternative strategy $s_i'$ that player $i$ could choose.

Replicator Dynamics describe how the proportion of agents using a strategy changes over time, based on its performance relative to the average.

$$\dot{x}_i = x_i(f_i - \bar{f})$$

$x_i$ is the fraction of the population using strategy $i$. $f_i$ is the fitness (payoff) of strategy $i$, and $\bar{f}$ is the average fitness of the whole population. If a strategy does better than average ($f_i > \bar{f}$), its share $x_i$ grows.

Real-World Applications

Auction & Bidding Design: Governments use game theory to design spectrum auctions for mobile networks. The goal is to structure payoffs so the Nash Equilibrium leads to efficient outcomes and fair prices, preventing bidders from gaming the system.

Traffic Flow & Routing: Apps like Waze or Google Maps create a massive game where each driver chooses a route. The Nash Equilibrium can be where no single driver can find a faster path, but this collective state is often worse (more congestion) than if a central planner assigned routes.

Evolutionary Biology: The Replicator Dynamics model directly applies to animal behavior. For instance, the proportion of "Hawk" (aggressive) vs. "Dove" (peaceful) strategies in a species will evolve based on the payoffs of fights over resources.

Cybersecurity & Network Defense: Security experts model attacks and defenses as a game. A company must allocate limited resources to protect various assets, while an attacker chooses targets. Finding the mixed-strategy Nash Equilibrium helps predict attack patterns and optimize defense spending.

Common Misconceptions and Points to Note

First, let go of the assumption that "the Nash equilibrium is the one and only 'correct answer.'" For example, in the "Stag Hunt" game, there are two Nash equilibria: "everyone cooperates" and "everyone defects." If you change the initial conditions in the simulator, you'll see the convergence shift between these equilibria. This illustrates that in real-world negotiations or markets, different equilibria can be realized depending on initial conditions or historical context (e.g., which technology gained adoption first).

Next, be aware of the pitfalls in setting parameters for evolutionary games. When you set the "update rule" to "best response," the strategy changes on the grid can become extremely fast and chaotic. Considering that real human or biological learning/imitation isn't that perfectly rational, this should prompt you to question whether the model might be overly simplistic. When applying these concepts in practice, remember that the choice of update rule significantly influences the outcomes, so you need to carefully consider the "learning mechanism" of the system you're studying.

Finally, understand that the "ordinal relationship" between payoffs is more fundamental than their "absolute values." In the Prisoner's Dilemma, the relationship between the temptation payoff for defection (T), the reward for mutual cooperation (R), the punishment for mutual defection (P), and the sucker's payoff for unilateral cooperation (S) is T > R > P > S. Even if you drastically increase the numerical value of the "reward R" from 10 to 100 in the simulator, as long as this ordinal relationship holds, the Prisoner's Dilemma structure remains, and defection stays dominant. When tweaking numbers, pay close attention to how this ordering changes.

Related Engineering Fields

The concepts behind this simulator are directly applicable to the design and analysis of multi-agent systems. For instance, in "cooperative control" for a fleet of autonomous vehicles deciding efficient crossing order at an intersection, or in "distributed robotics" where multiple robots transport materials, each agent (player) makes decisions based on local information. The conflicts and inefficiencies that arise here are precisely game theory problems. By observing "spatial evolutionary games" in the simulator, you can develop an intuition for how local interactions generate global patterns (like traffic jams or efficient flows).

Furthermore, the problem of frequency band allocation in wireless communication networks is another application of game theory. Each transmitter (player) chooses a frequency (strategy) to maximize its communication quality (payoff) while avoiding interference with others. This is similar to the "Stag Hunt" game: if everyone coordinates by choosing different frequencies, the overall payoff is maximized, but congestion occurs if too many flock to the best bands. Manipulating the payoff matrix in the simulator serves as foundational training for parameter tuning in the protocol design of such networks.

Moreover, there is an analogy with phase transition modeling in materials science. The dynamics where each cell on a grid holds a state of "cooperate" or "defect," changing based on interactions with neighboring cells, is mathematically similar to the "Ising model" for magnetism, where a spin is influenced by its neighbors. By changing parameters (e.g., payoffs or update probabilities), you can observe abrupt changes (phase transitions) between an "ordered state" where cooperation spreads and a "disordered state" where defection prevails. This offers a valuable perspective for understanding the emergence of macroscopic order in complex systems.

For Further Learning

The next step is to understand "Mixed Strategy Nash Equilibrium." The current tool only handles "pure strategies" (deterministically choosing cooperate or defect), but in reality, agents sometimes change their actions probabilistically. For example, in a soccer penalty kick, the kicker and goalkeeper randomly mix their choices of which side to kick or dive towards—this is a mixed strategy. Learning this will also help you recognize how the simulator's "mutation rate" might be generating unintended mixed-strategy-like behaviors.

If you wish to deepen the mathematical background, grasp the connection with "optimization problems." The concept of a Nash equilibrium can be viewed as the solution to a set of "intertwined optimization problems," where each player maximizes their own payoff function (taking other players' actions as given). In other words, game theory provides a framework for "distributed, competitive optimization." With this perspective, the previously mentioned multi-agent control and network resource allocation problems should come into clearer focus as "engineering problems."

Finally, if this tool has helped you appreciate the importance of "space," I strongly recommend exploring "Network Science." Real-world social networks or the internet don't have a uniform grid structure but possess complex network topologies. For your next learning step, try searching with keywords like "evolutionary games on scale-free networks." You'll learn about more realistic dynamics, such as how just a few "hubs" (highly connected individuals) can dramatically increase the overall cooperation rate across the system.