# Nash equilibrium in mixed strategies with p = 0

I am currently writing a program to calculate nash equilibria in mixed strategies. My algorithm simply tries a lot of different probabilites and then decides which one is the best. However I came across a game, where it didn't find a mixed strategy equilibrium. I then used Gambit to calculate the correct equilibrium and I saw that it simply sat the probability of one strategy to p = 0 and then completely ignored it and hence found an equilibrium (without the first strategy as its p was 0). So this is a legit equilibrium? And when should I tell my algorithm to set p = 0 and then try again? I also read about it as semi-mixed strategies, but when do you use them?

BTW, in the calculation of Gambit, the probability of the second players' strategies were kinda wrong as they only applied to the strategies of the first player which had p > 0 (the strategy with p = 0 wasn't considered in the calculation as it seems). So there is a better total outcome for player one if he chooses the strategy where Gambit said its probability is 0. Is this still legit?

This is the game:

+--------+------+-------+
|        | left | right |
+--------+------+-------+
| upper  | 2,2  | 5,1   |
| middle | 3,4  | 4,1   |
| lower  | 4,3  | 2,4   |
+--------+------+-------+


If player 2 mixes his strategies, then player 1 should always choose middle over an equal mix of upper and lower (since $3 = \frac{1}{2}(2+4)$ and $4 > \frac{1}{2}(5+2)$ ). This shows that the supports for P1's strategy could be {upper,middle} or {middle,lower}, or he could adopt a pure strategy.
For {upper,middle} the strictly dominant strategy is (middle, left), which is the only pure strategy NE in the full game. Player 1's $\text{payoff} = 3$.
• P1: play (middle,lower) with probabilities $(1/4,3/4)$. $\text{Payoff} = 10/3 > 3$.
• P2: play (left,right) with probabilities $(2/3,1/3)$.