10 CLS
20 LOCATE 1,32:COLOR 6,1:PRINT "BATTLE OF NUMBERS"
30 LOCATE 3,15:PRINT"The game starts with from 20 to 100 BLOCKS, you may"
40 LOCATE 4,18:PRINT "select the number or I will select the number"
50 LOCATE 6,17:PRINT"The object is to pick from 1 to a maximum number"
60 LOCATE 7,17:PRINT"of blocks, 3 to 10, you may select the number or"
70 LOCATE 8,29:PRINT"I will select the number"
80 LOCATE 10,14:PRINT"Taking turns (you first) You may select from 1 to the"
90 LOCATE 11,13:PRINT"maximum each time. You must take at least 1 and no more"
100 LOCATE 12,14:PRINT"than the maximum each time. Whoever picks up the last"
110 LOCATE 13,35:PRINT"BLOCK LOSES":COLOR 7,0
120 PRINT:PRINT TAB(20)"Do you wish to choose the limits? (Y OR N)";:L$=INPUT$(1):PRINT
130 PRINT:IF L$="N" THEN 200
135 IF L$<>"Y" THEN 120
140 PRINT TAB(18)"How many blocks would you like to start with?"
142 PRINT TAB(31)"(20 TO 100 PLEASE)";:INPUT N
150 IF N<20 OR N>100 THEN 142
160 PRINT:PRINT TAB(7)"What is the maximum number of blocks to be removed at any one time?"
170 PRINT TAB(30)"(From 3 to 10 please)";:INPUT K
180 IF K<3 OR K>10 THEN 170
190 GOTO 230
200 RANDOMIZE INT(TIMER/3)
210 N=20+CINT(80*RND)
220 K=3+CINT(7*RND)
230 CLS
240 R=INT(N/4)
250 IF N MOD 4 >0 THEN R=R+1
260 Y=10
262 IF N<6 THEN 272
264 P=0
270 FOR M=1 TO 3
272 IF N<6 THEN R=N
280 X=320-12*R
290 FOR I=1 TO R
292 IF (P MOD 2)=0 THEN CC=6 ELSE CC=4
310 X=X+24
320 NEXT I
322 IF N<6 THEN 395
330 Y=Y+10
340 NEXT M
350 X=320-12*(N-3*R)
395 IF N=1 THEN LOCATE 7,33:COLOR 7,1:PRINT "ONE BLOCK LEFT":GOTO 402
400 LOCATE 7,25:COLOR 7,1:PRINT "There are";N;"BLOCKS in the pile"
402 IF K>N THEN K=N
410 LOCATE 9,15:PRINT K;"Is the MAXIMUM number you can take at any one time":COLOR 7,0
420 LOCATE 11,22:PRINT "YOUR TURN, HOW MANY WILL YOU REMOVE";:INPUT XX
422 IF XX>0 AND XX<(K+1) THEN 440
430 LOCATE 13,29:PRINT"ILLEGAL MOVE TRY AGAIN"
432 FOR I=1 TO 500:NEXT I:LOCATE 13,1:PRINT STRING$(80," ")
434 GOTO 420
440 N=N-XX
450 IF N>0 THEN 510
460 CLS: LOCATE 13,31:COLOR 6,4:PRINT "***** I WIN *****":COLOR 7,0
470 LOCATE 17,19:PRINT "DO YOU WANT TO PLAY ANOTHER GAME? (Y OR N)":Z$=INPUT$(1)
473 LOCATE 17,1:PRINT STRING$(60," ")
480 IF Z$="N" THEN END
485 IF Z$<>"Y" THEN 470
490 LOCATE 17,36:PRINT "NEW GAME":FOR I=1 TO 500:NEXT I:CLS:GOTO 120
510 YY=(N-1) MOD (K+1)
520 IF YY=0 THEN 590
530 N=N-YY
535 IF N=0 THEN CLS:GOTO 640
540 LOCATE 13,35:PRINT "I TAKE";YY
545 IF N=1 THEN LOCATE 15,33:PRINT "ONE BLOCK LEFT":GOTO 570
560 LOCATE 15,22:PRINT "THERE ARE";N;"BLOCKS LEFT IN THE PILE"
570 FOR I=1 TO 1500:NEXT I
580 GOTO 230
590 IF N>1 THEN 620
600 YY=1
610 GOTO 530
620 YY=1+CINT((K-1)*RND)
630 GOTO 530
640 LOCATE 15,30:COLOR 5,0:PRINT "***** YOU WIN *****":COLOR 7,0
650 GOTO 470
660 END
