# NimHof # This Maple program computes the first M antidiagonals of the table of # Sprague-Grundy values for the game NimHof with a list of rules R, # where a rule [a,b] means that you can move from cell [x,y] # to any cell [x-i*a,y-i*b] as long as neither coordinate is negative. # Reference: Eric Friedman, Scott M. Garrabrant, Ilona K. Phipps-Morgan, A. S. Landsberg and Urban Larsson, Geometric analysis of a generalized Wythoff game, in Games of no Chance 5, MSRI publ. Cambridge University Press, date?] # mex := proc(L) local k; for k from 0 do if not k in L then return k; end if; end do: end proc: M:=12; A:=Array(0..M, 0..M, -1); A[0,0]:=0; R:=[[1,0], [2,1], [3,3], [0,1]]; Nr:=4; for d from 1 to M do for n from 0 to d do # what is nth cell A[x,y] in antidiagonal d? x:=d-n; y:=n; lis:=[]; for ir from 1 to Nr do for i from 1 to M do xp:=x-i*R[ir][1]; yp:=y-i*R[ir][2]; if xp<0 or yp<0 then break; else lis:=[op(lis),A[xp,yp]]; fi; od: # od i od: # od ir m:=mex(lis); #lprint("found",d,n,x,y,m); A[x,y]:=m; od: # od n od; #od d # print antidiagonals for d from 0 to M do lprint([seq(A[d-n,n],n=0..d)]); od: # print triangle for rw from 0 to M do lprint([seq(A[rw,i],i=0..M-rw)]); od: