clear E=100 % Size of lattice. N=11200 % Number of iterations. z(1:1:E^2)=-1; % Init lattice rotations (-1=right, 1=left) k(1:1:E^2)=0; k(1)=(E^2+E)/2; % Init the Ant @ 50,50 for t=1:1:N; k(t+1)=mod(k(t)+real(round((0.5*(E+1)*exp(i*pi/4*(trace(diag(z))-E^2)))-(0.5*(E-1)*exp(-i*pi/4*(trace(diag(z))-E^2)))))+imag(round((0.5*(E+1)*exp(i*pi/4*(trace(diag(z))-E^2)))-(0.5*(E-1)*exp(-i*pi/4*(trace(diag(z))-E^2))))),E^2); z(k(t+1)+1)=real(exp(2*i*pi/4*(1+z(k(t+1)+1)))); endfor; imagesc(reshape(z,E,E)) % Draw the Lattice