# Nash Equilibrium Finder

*Tags*: `ai`

, `lisp`

, *Date*: 2010-12-26

While I seem to be unable to make my mind up on a good interface to alphaâ€“beta with a few bells and whistles, I added a Nash equilibrium finder to Micmac, which is becoming less statistics oriented. This was one of the many things in Planet Wars that never really made it.

Let's consider the Matching pennies game. The row player wins iff the two pennies show the same side. The payoff matrix is:

```
| | Heads | Tails |
+-------+-------+-------+
| Heads | 1 | -1 |
| Tails | -1 | 1 |
```

Find the mixed strategy equilibrium:

```
(find-nash-equilibrium '((-1 1) (1 -1)))
=>
#(49 51)
#(50 50)
-0.01
```

That is, both players should choose heads 50% of the time and the expected payoff (for the row player) is zero of which -0.01 is an approximation:

```
(find-nash-equilibrium '((-1 1) (1 -1)) :n-iterations 1000)
=>
#(499 501)
#(500 500)
-0.001
```