rng(1, 'twister');

% gainA > 0
g = [  5, -8;  -2,  5 ];
x = 0.35; y = 0.65;    filename = 'zero_sum_game_result_1.png';
%x = 0.50; y = 0.50;    filename = 'zero_sum_game_result_1_050_050.png';
%x = 0.35; y = 0.50;    filename = 'zero_sum_game_result_1_035_050.png';

% gainA = 0
%g = [  4, -8;  -2,  4 ];
%x = 1/3; y = 2/3;      filename = 'zero_sum_game_result_2.png';

% gainA < 0
%g = [  3, -8;  -2,  3 ];
%x = 5/16; y = 11/16;   filename = 'zero_sum_game_result_3.png';

gainA = 0;

result = [];

for iteration=1:10000
    if rand < x A = 1; else A = 2; end
    if rand < y B = 1; else B = 2; end
    gainA = gainA + g(A,B);
    result = [ result; iteration, gainA ];
end

plot(result(:,1), result(:,2));
xlabel('iteration');
ylabel('gain of player A');
saveas(gcf, filename);
