function [p,z]=lowergamelp(B)

% B is payoff matrix which can be any m by n.
% This sovles the lowergame of B as a LP problem. \\
% minimize z under B*p <= z and sum(p)=1, p>0
% or minimize c*[p z]' under [B -1;-1 0;1 0][p z]' <=b

[m,n]=size(B);

B=[B -ones(m,1); [-ones(1,n) 0;ones(1,n) 0]];

b=[zeros(m,1);-1;1];
c=[zeros(n,1);1]';
lb=[zeros(n,1);-inf];

p=linprog(c,B,b,[],[],lb);
z=p(end); p=p(1:end-1);
