M=10000; % Number of simulations
lost = 0;
win = 0;
gamelength = zeros(1,M);
% disp('      win      loss    gamelength')

for k=1:M
    stop = 0;
    curr_gamelength = 1;
    x = sum(round(rand(1,2)*6+0.5));
    if (x==7) | (x==11)
        win = win+1;
        stop = 1;
    elseif (x==2) | (x==3) | (x==12)
        lost = lost+1;
        stop = 1;
    else
        point = x;
    end
    while ~stop
        curr_gamelength = curr_gamelength+1;
        x = sum(round(rand(1,2)*6+0.5));
        if (x==7)
            lost=lost+1;
            stop = 1;
        elseif (x==point)
            win = win+1;
            stop = 1;
        end
    end
    gamelength(k) = curr_gamelength;
%    disp(sprintf('%8.0f  %8.0f  %8.0f '...
%        ,win, lost, curr_gamelength))
end
