nim *ħ{ Spectrum NIM David Lawrence 87:7:0::0:0:0 Ux="a"+1"a"+6:x,129:x:"a",255:"a"+7,255  2510  1760  1900l $ig(1)+g(2)+g(3)+g(4)+g(5)=02;"Rotter! You won.":9000(# 8 1280 Bhg(1)+g(2)+g(3)+g(4)+g(5)=01;"Tee-hee! I won.":9000(# Vu$="00000"2220 ` 1050 j ti=1297 ~?k=g(i/7+1)1-1:.05|L,k-10 %20-k,i;2;4;"" k E3,i-1;"(";g(i/7+1);")":.075},0 ,20,i;1;(491+i/7) i  50,0;" " %1,0;" "   b2=0  i=15  t$="00000" n=g(i) (7j=51-1:.01z# =,j:.01z# =,-j 2#n/2ɺ(n/2)t$(j)="1" <n=(n/2) Fj P b1=(t$) Z b2=b2+b1 di  s$=(b2)  t$="00000" t$(6-s$5)=s$  u$="00000" i=15  n=(t$(i)) $n/2ɺ(n/2)1510 i   u$(i)="1"  v$="00000" @j=i+15:.01z# =,2*j:.01z# =,-2*j  n=(t$(j)) #n/2ɺ(n/2)v$(j)="1" j " 2330 , s=0 Ti=51-1 ^$u$(i)"0"s=s+2^(5-i) h.v$(i)="1"w$(i)="0"s=s-2^(5-i) r.v$(i)="1"w$(i)="1"s=s+2^(5-i) |i \0,0;"I will take ";s;" from pile ";p:.25~,-10 :.25~,10  100d  g(p)=g(p)-s  1130j   g(5) g(1)=(*13 ) g(2)=(*13 ) 2g(3)=(*(27-g(1)-g(2))) &+g(3)>16 g(3)=16 0=g(4)=(*(30-g(3)-g(2)-g(1))) :*g(4)>16g(4)=16 DAg(5)=32 -g(4)-g(3)-g(2)-g(1) N!g(5)>161800 X 1130j b 40,0;"Which pile? ";:.1}L,0 m1 m1 -m1<6m1>0m1=(m1):2020 C0,0;"There are only five piles!":.5,-20  502  1220  1930 g(m1)>02080  ?0,16;"Nothing in that pile!":.5,-20  70F  1220  1930  30,16;"How many? ";:.1}L,0 *m2 4m2 >+m2>0m2g(m1)m2=(m2):2170z H60,16;"You can't! ":.5,-20 R 100d f 1230 p 2080  zg(m1)=g(m1)-m2  502  1130j   s=0 i=15 g(i)>sp=i:s=g(i) i  s=1  1670  8pile=2^(5-i) Bi=15 L)g(i)pileg(i)<2*pile2430~ `$g(i)-pile2*pile2430~ ji t ~p=i w$="00000" c=g(p) i=15 +c/2ɺ(c/2)w$(6-i)="1" c=(c/2) i  "10 ;"Spectrum NIM" 4,0;"I will display five piles of","counters. On each move you cantake any number of counters, up to and includind all of them -- but only from one pile!"'''"The winner is the one to take the last counter." 'i$="Press any key to continue......." N18,0;6;1;1;i$:i$=i$(2)+i$(1) =""2560  #(A"Play again ?";i$:i$(1)="Y"i$(1)="y"1040 #2 _^ $t~I ..Press any key to continue.....