I spent 8 weeks building a Nash Equilibrium calculator from scratch in Python

Published: (March 30, 2026 at 12:25 PM EDT)
1 min read
Source: Dev.to

Source: Dev.to

Overview

I wanted to apply computer science to economics and mathematics, so I built a Nash Equilibrium calculator using Python and libraries such as numpy and scipy.optimize.

Features

  • Calculates all pure and mixed Nash equilibria using the support enumeration algorithm.
  • Employs linear programming via the HiGHS solver for the iterated elimination of strictly dominated strategies.
  • Sub‑feature computes game values for zero‑sum games using the von Neumann Minimax theorem by:
    • Identifying Pareto‑optimal outcomes
    • Calculating the social welfare loss
  • Uses the rich library to build a terminal UI that color‑codes the matrices for easy readability.

Implementation Details

  • Language: Python
  • Key libraries: numpy, scipy.optimize, HiGHS, rich

Development Process

  • The project took almost 8 weeks to complete.
  • I deliberately avoided using AI assistance, so the code may have some rough edges.

Repository

GitHub repository

0 views
Back to Blog

Related posts

Read more »

Prime number

What is a prime number? Important Notes - Numbers less than or equal to 1 are not prime JavaScript javascript let num = Numberprompt'Enter a number: '; let div...