%I #43 Oct 27 2019 21:41:15
%S 0,2,0,-2,-1,1,2,1,-1,-2,0,2,1,-1,-2,-1,1,0,-2,-1,-2,0,2,1,2,3,1,-1,
%T -3,-4,-3,-4,-2,0,2,4,3,4,3,1,-1,-3,-4,-3,-4,-3,-1,1,3,4,3,4,2,0,-2,
%U -4,-3,-4,-3,-1,1,3,4,3,4,2,0,-2,-4,-3,-4,-3,-4,-2,0
%N x-coordinates of a counterclockwise knight's tour on an infinite board starting at the origin and then successively visiting fields in concentric rings of width 2. y-coordinates are in A306660.
%C The tour starts with a prescribed initial move (0,0) -> (2,1). It then proceeds to the next field (x,y) not yet visited, satisfying the "ring" conditions
%C !(abs(x) < liminn and abs(y) < liminn) and abs(x) <= limout and abs(y) <= limout, with liminn=1, limout=2 in the first round, liminn=3, limout=4 in the second round, liminn=5, limout=6 in the third round, ...
%C Each move is selected from the list of the 8 possible moves, such that the angular difference between the polar angles of the starting point and the target point achieves the minimum of the available positive values. This guarantees the counterclockwise advancing of the tour.
%C When all fields inside a ring have been visited, an extension step continuing the last used direction inside the preceding inner ring is performed, thus establishing the first visited field in the next ring.
%C The selection method continues by successively visiting fields in the current ring until no more free fields are available.
%C A similar method of construction is used in A068608 and its 7 companion sequences. In contrast to the present sequence, initial steps are chosen such that the extension steps are parallel to the initial step. Clockwise advancement is used in A068608-A068611, counterclockwise advancement is used in A068612-A068615. The tour's visited fields are then mapped to a clockwise square number spiral starting with number 1 for the origin and first step to (0,1).
%H Hugo Pfoertner, <a href="/A306659/b306659.txt">Table of n, a(n) for n = 1..1089</a>
%H Hugo Pfoertner, <a href="/A306659/a306659.png">Illustration of knight's tour on 13 X 13 board</a>.
%H Jay Warendorff, <a href="http://demonstrations.wolfram.com/AnInfiniteKnightsTour/">An Infinite Knight's Tour</a>, Wolfram Demonstrations Project, March 7 2011.
%o (PARI) atan2(y,x)=if(x>0,atan(y/x),if(x==0,if(y>0,Pi/2,-Pi/2),if(y>=0,atan(y/x)+Pi,atan(y/x)-Pi)));
%o angle(v,w)=atan2(v[1]*w[2]-v[2]*w[1],v[1]*w[1]+v[2]*w[2]);
%o move=[2,1;1,2;-1,2;-2,1;-2,-1;-1,-2;1,-2;2,-1]; \\ 8 Knight moves
%o m=6; \\ Extension of board - 2
%o b=matrix(2*m+1,2*m+1,i,j,0); \\ Visited fields
%o ptarget=1; \\ change to 2 to print A306660
%o setb(pos)={b[pos[1]+m+1,pos[2]+m+1]=1}; \\ Mark visited fields
%o getb(pos)=b[pos[1]+m+1,pos[2]+m+1]; \\ Check visited fields
%o inring(n,p)=!(abs(p[1])<n&&abs(p[2])<n)&&abs(p[1])<=n+1&&abs(p[2])<=n+1;
%o p=[0,0];setb(p);print1(p[ptarget],", ");p+=move[1,];setb(p);forstep(n=1,m-3,2,my(angmin,jmin,jlast);until(jmin==0,print1(p[ptarget],", ");angmin=2*Pi;jmin=0;for(j=1,#move[,1],my(ptry=p+move[j,],adiff);if(inring(n,ptry),if(!getb(ptry),adiff=angle(p,ptry);if(adiff>=0,if(adiff<angmin,jmin=j;angmin=adiff;jlast=j)))));if(jmin>0,p+=move[jmin,];setb(p);););p+=move[jlast,];setb(p));
%Y Cf. A068608, A068609, A068610, A068611, A068612, A068613, A068614, A068615, A306660.
%K sign
%O 1,2
%A _Hugo Pfoertner_, May 05 2019