1 ' ** NIM ** Computing With The Amstrad (June 1985)
2 '
3 INK 0,0:BORDER 0:PAPER 0:MODE 2:CLS:INK 1,15:PEN 1
5 CLS
10 PRINT " *** NIM *** ":PRINT " You must try and leave the computer the last match and it will attempt the sameon you."
11 PRINT "You CAN'T take more than half the matches":PRINT
12 n=INT(RND*1000)+100
20 PRINT"There are "N" matches at the start"
30 IF RND>0.8 THEN 80
40 INPUT "How many matches do you wish to take ";M
50 IF m>n/2 THEN 40
60 n=n-m
70 PRINT"You have left "n" matches"
80 i=1
90 i=i*2
100 IF i<=n THEN 90
110 i=i/2-1
120 IF 2*i<n THEN i=n-1
130 PRINT "I take "N-i" leaving "i
140 n=i
150 IF n>1 THEN 40
160 IF n=1 THEN PRINT"I Win" ELSE PRINT "I Lose"
170 PRINT"Another game":PRINT "-------------------------------------":PRINT:PRINT:GOTO 10