tinyBas2 - Matches

10 REM ** Marienbad Game **
20 Z=TICKS
30 Z=Z/1000-Z\1000
40 L=50 : GOTO 910
50 N=(Z*29)\1+2
60 CLS : PRINT "Matches" : PRINT ""
70 L=80 : GOTO 810
80 PRINT "Please choose who will start"
90 PRINT "first to remove matches:"
100 PRINT "[1] Me (Computer)"
110 PRINT "[2] You (Human)"
120 INPUT F
130 IF F=1 THEN GOTO 210
140 IF F=2 THEN GOTO 410
150 GOTO 120

200 REM ** Computer plays
210 M=N-1 : M=M-(M\4)*4
220 IF M>0 THEN R=M : GOTO 260
230 L=240 : GOTO 910
240 R=(Z*3)\1+1
250 IF R>=N THEN GOTO 230
260 PRINT "I"; 
270 K=280 : GOTO 710
280 IF N>1 THEN GOTO 410
290 PRINT ""
300 PRINT "Sorry, I win !"
310 GOTO 610

400 REM ** Human plays
410 PRINT "Remove how many matches ?"
420 INPUT R
430 B=(R>=1)*(R<=3)*(R=(R\1))*(R<N)
440 IF B=0 THEN GOTO 420
450 PRINT "You";
460 K=470 : GOTO 710
470 IF N>1 THEN GOTO 210
480 PRINT ""
490 PRINT "Good job, you win."

600 REM ** Play again ?
610 PRINT ""
620 PRINT "Do you wish to play again ?"
630 PRINT "[1] Yes"
640 PRINT "[2] No"
650 INPUT F
660 IF F=1 THEN GOTO 40
670 IF F=2 THEN END
680 GOTO 650

700 REM ** Nb matches removed
710 PRINT " remove ";
720 PRINT R;
730 PRINT " match";
740 IF R>1 THEN PRINT "es";
750 PRINT "..."
760 N=N-R : L= 770 : GOTO 810
770 GOTO K

800 REM ** Nb matches left
810 PRINT "There ";
820 IF N=1 THEN PRINT "is ";
830 IF N>1 THEN PRINT "are ";
840 PRINT N;
850 PRINT " match";
860 IF N>1 THEN PRINT "es";
870 PRINT " left" : GOTO L

900 REM ** Random generator
910 Z=221*Z+0.2113
920 Z=Z-Z\1 : GOTO L
