for x = 1:3
    if sum(MainGame(x,:))==3|sum(MainGame(:,x))==3|(MainGame(1)+MainGame(5)+MainGame(9))==3|(MainGame(7)+MainGame(5)+MainGame(3))==3
        CurrentWinner = 'O';
        if CurrentPlayer == 'Compu' %Means that last turn was Human's
            Wins = get(findobj('tag','WinNumST'),'string');
            Wins = str2num(Wins) + 1;
            set(findobj('tag','WinNumST'),'string',num2str(Wins))
        else
            Losses = get(findobj('tag','LossesNumST'),'string');
            Losses = str2num(Losses) + 1;
            set(findobj('tag','LossesNumST'),'string',num2str(Losses))
        end
        StartNewGame=false;
        GameOver=true;
        return
    end
    if sum(MainGame(x,:))==-3|sum(MainGame(:,x))==-3|(MainGame(1)+MainGame(5)+MainGame(9))==-3|(MainGame(7)+MainGame(5)+MainGame(3))==-3
        CurrentWinner = 'X';
        if CurrentPlayer == 'Compu' %Means that last turn was Human's
            Wins = get(findobj('tag','WinNumST'),'string');
            Wins = str2num(Wins) + 1;
            set(findobj('tag','WinNumST'),'string',num2str(Wins))
        else
            Losses = get(findobj('tag','LossesNumST'),'string');
            Losses = str2num(Losses) + 1;
            set(findobj('tag','LossesNumST'),'string',num2str(Losses))
        end
        StartNewGame=false;
        GameOver=true;
        return
    end
end

if GameOver == false
    for x = 1:9
        if MainGame(x) == 0
            return %MainGame is not full, therefore no chance for a tie
        end
    end
    Ties = get(findobj('tag','TiesNumST'),'string');
    Ties = str2num(Ties) + 1;
    set(findobj('tag','TiesNumST'),'string',num2str(Ties))
    GameOver = true;
    StartNewGame=false;
end