function [S1,J1,P1,S2,J2,P2]= Echange(S1,J1,P1,S2,J2,P2,Qui)
%UNTITLED5 Summary of this function goes here
% Detailed explanation goes here
if (Qui == 1)
if (P1 == 0)
P1 = 15;
else
if (P1 == 15)
P1 = 30;
else
if (P1 == 30)
P1 = 40;
else
if ( (P2 == 40) && (P1 == 40))
P1 = 50;
else
if ( ((P1 == 40) && (P2 < 40)) || ((P1 == 50) && (P2 == 40)) )
P1 = 0;
P2 = 0;
J1 = J1 + 1
if ( (J1 >= 6) && ((J1-J2) > 1) )
S1 = S1 + 1;
J1 = 0;
J2 = 0;
end
else
P1 = 40;
P2 = 40;
end
end
end
end
end
else
if (P2 == 0 )
P2 = 15
else
if (P2 == 15)
P2 = 30;
else
if (P2 == 30)
P2 = 40;
else
if ((P1 == 40) && (P2 == 40))
P2 = 50;
else
if ( ((P2 == 40) && (P1 < 40)) || ((P2 == 50) && (P1 == 40)) )
P1 = 0;
P2 = 0;
J2 = J2 + 1;
if ( (J2 >= 6) && ((J2-J1) > 2) )
S2 = S1+1;
J1 = 0;
J2 = 0;
end
else
P1 = 40;
P2 = 40;
end
end
end
end
end
end