t:= 2 ; # to get about t times 1000 terms h:= proc() false end: v:= proc() false end: d:= proc() false end: u:= proc() false end: h(0), v(0), d(0), u(0):=true$4: xy:=[0, 0]: l:=0: n:=0: dd:= 1: dir:= [[1, 0], [0, 1], [-1, 0], [0, -1]]: for len to 1430*t do for s to 2 do for hh to len do n:= n+1; xy:= xy+dir[dd]; x, y:=xy[]; if h(y) or v(x) or d(x+y) or u(x-y) then if (dd::odd) and h(y) or (dd::even) and v(x) then xy:= xy+dir[dd]*(len-hh); n:= n+(len-hh); break fi else h(y), v(x), d(x+y), u(x-y):=true$4; l:=l, n; fi od; dd:= (dd mod 4)+1 od; if (len mod 710)=1 then print(len, nops([l])) fi od: a:= i-> l[i+1]: nn:= nops([l]); # this many terms we got seq(a(n), n=0..60); # first few terms