function midPt = chaosPos(i,P)
global seq corner_g corner_t corner_a corner_c
%i is iteration, and the index of the current nucleotide in genetic sequence
%P is coordinates of initial point

%for completely Random Chaos Game (unweighted dice)
%This runs for each letter in the text file
prb=rand();
runIf = 'GgTtAaCc';
endPt=P; %for all characters read in this iteration i that are not a DNA base
for k=1:length(runIf)
    if seq(i)==runIf(k)
        if prb<0.25
            endPt=corner_g;
        elseif prb<0.5
            endPt=corner_t;
        elseif prb<0.75
            endPt=corner_a;
        else
            endPt=corner_c;
        end
        break %the base has been identified, so a new point can be plotted
    end
end

midPt=[(P(1)+endPt(1))/2,(P(2)+endPt(2))/2];
