zero-sum game solved in Matlab

In Zero-Sum games, a player can win, only if the other player looses. Rock-paper-scissors is a typical example of a zero-sum game. These games can be solved with Linear Programming (LP) because the latter has duals. So, how to solve this game in Matlab? This post is an extension to my previous post dealing with LP. The problem is to minimize a function z = f(rock,paper,scissors) = f (x1,x2,x3) equal to some payoff value v, subject to the following game conditions:

   -------->    

to solve in Matlab, we must rearrange the constraints to include v as a variable (right). The game matrix is:


A = [0 -1 1 1; 1 0 -1 1; -1 1 0 1];
b = [0 0 0];
Aeq = [1 1 1 0];
beq = 1;
lb = [0 0 0 -inf]; % here the lower bound of v has not to necessarily zero, but in a general game could be minus infinity. 
% Objective function
f = [0 0 0 -1];
% Solve the LP 
z = linprog(f,A,b,Aeq,beq,lb);
% Payoff 
v = z(4)
% Probability of the variables 
x = z(1:3)


v =
     0

x =
    0.3333
    0.3333
    0.3333

No comments:

Post a Comment