n = 10;
historySize = 500;
outputSize = 15;
x=zeros(historySize,3);
score = 0;
AIscore = 0;
maxIndex = round(rand(1)*2)+1;
while(true)
    entry = input('Enter 1 (rock), 2 (paper), or 3 (scissors): ');
    
    if (isempty(entry) || (entry~=1 && entry~=2 && entry~=3)) continue; end;
    x = [x(2:historySize,1:3);zeros(1,3)];
    x(historySize,entry) = 1;
    A = lpc(x,n);
    result = zeros(1,3);
    for i=1:n
        result(1,1) = result(1,1) - A(1,i+1)*x(historySize-i+1,1);
        result(1,2) = result(1,2) - A(2,i+1)*x(historySize-i+1,2);
        result(1,3) = result(1,3) - A(3,i+1)*x(historySize-i+1,3);
    end
    
    if (maxIndex==1) display('AI chooses paper'); end
    if (maxIndex==2) display('AI chooses scissors'); end
    if (maxIndex==3) display('AI chooses rock'); end
    if (entry==3&&maxIndex==3)||(entry==2&&maxIndex==2)||(entry==1&&maxIndex==1); AIscore=AIscore+1; display('AI wins');
    elseif (entry == 2&&maxIndex==3)||(entry==1&&maxIndex==2)||(entry==3&&maxIndex==1); score=score+1; display('You win');
    else display('Tie');
    end
    display(sprintf('Your score: %d   AI score: %d',score,AIscore));
    
    maxValue = -1000000;
    maxIndex = 1;
    if (result(1,1)>maxValue)
        maxValue = result(1,1);
        maxIndex = 1;
    end
    if (result(1,2)>maxValue)
        maxValue = result(1,2);
        maxIndex = 2;
    end
    if (result(1,3)>maxValue)
        maxIndex = 3;
    end
end

