Engineering Notes

Engineering Notes

Thoughts and Ideas on AI by Muthukrishnan

Understanding Multi-Agent Behavior with Game Theory and Nash Equilibrium

05 Oct 2025

Concept Introduction

Game Theory is the mathematical study of strategic decision-making among rational, self-interested agents. It is the standard framework for analyzing how AI agents behave in environments where their goals may conflict or align with others.

The central concept is the Nash Equilibrium: a state where no player can improve their outcome by unilaterally changing their strategy, assuming all others hold theirs fixed. It represents a stable outcome, though not always an optimal one.

The Prisoner’s Dilemma illustrates this clearly. Two suspects are held in separate rooms. If both stay silent, both serve 1 year. If one betrays the other while the other stays silent, the betrayer goes free and the silent one serves 5 years. If both betray, both serve 3 years. Each player’s dominant strategy is to betray, and the result is worse for both than mutual silence would have been.

Historical & Theoretical Context

While ideas of strategic thinking are ancient, modern game theory was pioneered by mathematician John von Neumann in the 1920s and solidified in his 1944 book Theory of Games and Economic Behavior with Oskar Morgenstern. Their work focused on “zero-sum” games where one player’s gain is another’s loss.

The field was revolutionized in the 1950s by John Nash, who introduced the concept of the Nash Equilibrium. His work extended game theory to a much wider class of “non-cooperative” games, where players are not necessarily in direct opposition. This breakthrough, for which he later won a Nobel Prize, provided a powerful way to predict the behavior of complex systems, from economics and politics to AI.

The Math: Payoff Matrices and Finding Equilibrium

To analyze a game, we need to define its components:

Let’s model the Prisoner’s Dilemma. The payoffs are the years in prison (we’ll use negative numbers, since less prison time is better).

Payoff Matrix (Prisoner A’s Payoff, Prisoner B’s Payoff):

Prisoner B: Stays SilentPrisoner B: Betrays
A: Stays Silent(-1, -1)(-5, 0)
A: Betrays(0, -5)(-3, -3)

How to find the Nash Equilibrium: We analyze the choices from each player’s perspective.

  1. Prisoner A’s Thought Process:

    • If Prisoner B stays silent, my best move is to Betray (0 years is better than -1 year).”
    • If Prisoner B betrays, my best move is to Betray (-3 years is better than -5 years).”
    • No matter what B does, A is better off betraying. This is a “dominant strategy.”
  2. Prisoner B’s Thought Process:

    • The logic is identical. No matter what A does, B is better off betraying.

The stable outcome, where neither player has an incentive to change their mind given the other’s choice, is (Betray, Betray). This is the Nash Equilibrium. Notice that this outcome (-3, -3) is worse for both players than the cooperative outcome of (-1, -1), which is what makes the dilemma so compelling.

Design Patterns & Architectures

Practical Application

Here’s a simple Python snippet to find the Nash Equilibrium in any 2x2 game with two strategies per player.

def find_nash_equilibrium(payoff_matrix):
    """
    Finds the pure strategy Nash Equilibrium for a 2x2 game.
    Payoff matrix format: [[(A1_B1, B1_A1), (A1_B2, B2_A1)],
                           [(A2_B1, B1_A2), (A2_B2, B2_A2)]]
    where A1_B2 is Player A's payoff when A plays strategy 1 and B plays strategy 2.
    """
    # Check Player A's best response
    a_best_if_b1 = 0 if payoff_matrix[0][0][0] >= payoff_matrix[1][0][0] else 1
    a_best_if_b2 = 0 if payoff_matrix[0][1][0] >= payoff_matrix[1][1][0] else 1

    # Check Player B's best response
    b_best_if_a1 = 0 if payoff_matrix[0][0][1] >= payoff_matrix[0][1][1] else 1
    b_best_if_a2 = 0 if payoff_matrix[1][0][1] >= payoff_matrix[1][1][1] else 1

    equilibria = []
    # Check each of the four outcomes to see if it's a stable pair
    # Is (A1, B1) a Nash Equilibrium?
    if a_best_if_b1 == 0 and b_best_if_a1 == 0:
        equilibria.append("Strategy (A1, B1)")
    # Is (A1, B2) a Nash Equilibrium?
    if a_best_if_b2 == 0 and b_best_if_a1 == 1:
        equilibria.append("Strategy (A1, B2)")
    # Is (A2, B1) a Nash Equilibrium?
    if a_best_if_b1 == 1 and b_best_if_a2 == 0:
        equilibria.append("Strategy (A2, B1)")
    # Is (A2, B2) a Nash Equilibrium?
    if a_best_if_b2 == 1 and b_best_if_a2 == 1:
        equilibria.append("Strategy (A2, B2)")
        
    return equilibria

# Payoffs: (Player A, Player B)
prisoners_dilemma = [
    [(-1, -1), (-5, 0)],  # A: Silent, B: Silent | A: Silent, B: Betray
    [(0, -5), (-3, -3)]   # A: Betray, B: Silent | A: Betray, B: Betray
]

# A1=Silent, A2=Betray. B1=Silent, B2=Betray.
# The Nash Equilibrium is (A2, B2)
print(f"Prisoner's Dilemma Nash Equilibrium: {find_nash_equilibrium(prisoners_dilemma)}")

Latest Developments & Research

Cross-Disciplinary Insight

Game theory is one of the most widely applied ideas in science.

Daily Challenge / Thought Exercise

Think about the daily interaction of two cars arriving at an intersection at the same time.

References & Further Reading

  1. Stanford Encyclopedia of Philosophy - Game Theory: https://plato.stanford.edu/entries/game-theory/ (A comprehensive and rigorous introduction).
  2. Khan Academy - Prisoner’s Dilemma and Nash Equilibrium: https://www.khanacademy.org/economics-finance-domain/microeconomics/nash-equilibrium-tutorial (Great video introductions).
  3. Silver, D., et al. (2016). Mastering the game of Go with deep neural networks and tree search. Nature. (The original AlphaGo paper, showcasing the power of RL in complex games).

● Intelligence at Every Action

AI Native
Project Management

Stop using tools that bolt on AI as an afterthought. Jovis is built AI-first — smart routing, proactive monitoring, and intelligent workflows from the ground up.