Nash equilibrium in Python

Hooked picture Hooked · Feb 4, 2011 · Viewed 9.3k times · Source

Is there a Python library out there that solves for the Nash equilibrium of two-person zero-games? I know the solution can be written down in terms of linear constraints and, in theory, scipy should be able to optimize it. However, for two-person zero-games the solution is exact and unique, but some of the solvers fail to converge for certain problems.

Rather than listing any of the libraries on Linear programing on the Python website, I would like to know what library would be most effective in terms of ease of use and speed.

Answer

Rafe Kettler picture Rafe Kettler · Feb 4, 2011

Raymond Hettinger wrote a recipe for solving zero-sum payoff matrices. It should serve your purposes alright.

As for a more general library for solving game theory, there's nothing specifically designed for that. But, like you said, scipy can tackle optimization problems like this. You might be able to do something with GarlicSim, which claims to be for "any kind of simulation: Physics, game theory..." but I've never used it before so I can't recommend it.