I spent 8 weeks building a Nash Equilibrium calculator from scratch in Python
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.