This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A306659 #43 Oct 27 2019 21:41:15 %S A306659 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 A306659 -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 A306659 -4,-3,-4,-3,-1,1,3,4,3,4,2,0,-2,-4,-3,-4,-3,-4,-2,0 %N A306659 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 A306659 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 A306659 !(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 A306659 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 A306659 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 A306659 The selection method continues by successively visiting fields in the current ring until no more free fields are available. %C A306659 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 A306659 Hugo Pfoertner, <a href="/A306659/b306659.txt">Table of n, a(n) for n = 1..1089</a> %H A306659 Hugo Pfoertner, <a href="/A306659/a306659.png">Illustration of knight's tour on 13 X 13 board</a>. %H A306659 Jay Warendorff, <a href="http://demonstrations.wolfram.com/AnInfiniteKnightsTour/">An Infinite Knight's Tour</a>, Wolfram Demonstrations Project, March 7 2011. %o A306659 (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 A306659 angle(v,w)=atan2(v[1]*w[2]-v[2]*w[1],v[1]*w[1]+v[2]*w[2]); %o A306659 move=[2,1;1,2;-1,2;-2,1;-2,-1;-1,-2;1,-2;2,-1]; \\ 8 Knight moves %o A306659 m=6; \\ Extension of board - 2 %o A306659 b=matrix(2*m+1,2*m+1,i,j,0); \\ Visited fields %o A306659 ptarget=1; \\ change to 2 to print A306660 %o A306659 setb(pos)={b[pos[1]+m+1,pos[2]+m+1]=1}; \\ Mark visited fields %o A306659 getb(pos)=b[pos[1]+m+1,pos[2]+m+1]; \\ Check visited fields %o A306659 inring(n,p)=!(abs(p[1])<n&&abs(p[2])<n)&&abs(p[1])<=n+1&&abs(p[2])<=n+1; %o A306659 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 A306659 Cf. A068608, A068609, A068610, A068611, A068612, A068613, A068614, A068615, A306660. %K A306659 sign %O A306659 1,2 %A A306659 _Hugo Pfoertner_, May 05 2019