Type: Program
Platform(s): TS 2068
Play the one-armed bandit.
10 REM "LAS VEGAS" 100 DIM R(3,13): DIM J(13): LET J(5)=1: LET J(6)=1: LET J(7)=1 110 LET W$="AKQJ7*$0/=+#%" 120 FOR I=5 TO 12: READ R(2,I),R(3,I): NEXT I 130 DATA 8,40,8,40,7,30,5,25,3,20,3,20,2,10,2,10 140 DIM H(3): DIM P(3): DIM C(4): DIM D(4) 150 DIM K(3): DIM V(4): DIM O(3): DIM A(3) 160 DIM F(3): DIM G(4): DIM E(4,2) 170 FOR I=1 TO 3: READ P(I): NEXT I 180 FOR I=1 TO 4: READ D(I): READ E(I,1): READ E(I,2): NEXT I 190 DATA 12,14,16,12,1,14,13,2,20,15,3,14,16,2,9 200 LET B$=" ": REM 13* 210 LET NT=-1: LET NJ=4: LET NI=0: LET WI=0 220 LET HB=0: LET DO=0: LET DC=0: LET JA=0 230 LET JC=0: LET MO=0: LET MM=0: LET R=0: LET GW=0: LET NH=0: LET NG=0 240 FOR I=1 TO 3: LET V(I)=INT (RND*14): NEXT I 600 GO TO 4000 1000 REM ***FLASH $ AND GET INKEY$*** 1010 PRINT AT R,C; OVER 1; FLASH 1;S$; 1020 LET I$=INKEY$: IF I$="" THEN GO TO 1020 1030 PRINT AT R,C; PAPER CL;T$ 1040 RETURN 1100 REM **ADD INCREMENT TO MONEY** 1110 FOR I=SGN (IN) TO IN STEP SGN (IN) 1120 PRINT AT 0,7;MO+I;" ";: BEEP .1,40: NEXT I 1130 LET MO=MO+IN: RETURN 1200 REM ***REMOVE DOUBLE*** 1210 LET DO=0: PRINT AT 6,11; PAPER 2;" "; 1220 FOR I=1 TO 4: PRINT AT 7,D(I);W$(I);: LET C(I)=0: NEXT I: RETURN 1300 REM ***CLEAR LAST LINE*** 1310 PRINT AT 21,0;TAB 31;"";: RETURN 1400 REM ***JACKPOT*** 1410 FOR T=1 TO 4: FOR C=1 TO JC: PRINT AT 0,11+C;" ";: NEXT C 1420 FOR C=1 TO JC: BEEP .1,10+2*C: PRINT AT 0,11+C;"J";: NEXT C 1430 NEXT T: RETURN 1500 REM ***FLASH POSSIBLE HOLDS AND GET INKEY$*** 1510 FOR I=1 TO 3: IF H(I)=0 THEN PRINT AT 11,P(I); FLASH 1; PAPER 2; INK 7; OVER 1;"H"; 1520 NEXT I: LET HO=0 1530 LET I$=INKEY$: IF I$="" THEN GO TO 1530 1540 IF I$<>"1" AND I$<>"2" AND I$<>"3" THEN GO TO 1570 1550 LET I=VAL I$: PRINT AT 11,P(I); PAPER 2; INK 7;"H"; 1560 LET HO=1: LET H(I)=1: GO TO 1530 1570 FOR I=1 TO 3: IF H(I)=0 THEN PRINT AT 11,P(I); PAPER 2;" "; 1580 NEXT I: LET NH=NH+HO: RETURN 2000 REM ***DRAW SCREEN*** 2010 PRINT AT 5,11; PAPER 3;" "; 2020 FOR I=0 TO 4: PRINT AT 6+I,10; PAPER 3;" "; PAPER 2;" "; PAPER 3;" "; PAPER 7;" "; PAPER 3;" ";: NEXT I 2030 PRINT AT 6,20; PAPER 2;" ";: PRINT AT 10,19; PAPER 3;" "; 2040 FOR I=0 TO 2: PRINT AT 9,12+2*I; PAPER 6;" ";: NEXT I 2050 PRINT AT 11,11; PAPER 5;" "; 2060 FOR I=0 TO 2: PRINT AT 11,12+2*I; PAPER 6;" ";: NEXT I 2070 FOR I=0 TO 3: PRINT AT 12+I,12; PAPER 5;" ";: NEXT I 2080 FOR I=0 TO 3: FOR K=0 TO 4+2*I: PRINT AT 16+I,12-I+K; PAPER 1;" ";: NEXT K: NEXT I 2090 PRINT AT 0,0;"TOTAL: 0"; 2100 PRINT AT 8,0;"--%--= 1"; 2110 FOR I=12 TO 5 STEP -1 2120 PRINT AT 21-I,0;"-";W$(I);W$(I);"- = ";R(2,I); 2130 PRINT AT 21-I,22;W$(I);W$(I);W$(I);" = ";R(3,I); 2140 IF J(I) THEN PRINT "+J" 2150 NEXT I: RETURN 2300 REM ***ADAPT VARIABLES**** 2310 LET NT=NT+1: IF WI>0 THEN LET HB=1: LET WI=0 2320 FOR I=1 TO 3: LET H(I)=0: PRINT AT 11,P(I); PAPER 2;" ";: NEXT I 2330 IF DO THEN GO TO 2380 2340 FOR I=1 TO 4: IF C(I)=0 THEN GO TO 2370 2350 LET C(I)=C(I)-1: IF C(I)>0 THEN GO TO 2370 2360 LET NJ=NJ+1: PRINT AT 7,D(I);W$(I); 2370 NEXT I: GO TO 2390 2380 LET DC=DC-1: IF DC=0 THEN GO SUB 1200 2390 IF JA THEN PRINT AT 0,11+JC;" ";: LET JC=JC-1: IF JC=0 THEN LET JA=0 2400 IF MO>MM THEN LET MM=MO 2410 RETURN 2500 REM ***NOT ENOUGH MONEY*** 2510 LET HB=1: GO SUB 1200 2520 LET JA=0: PRINT AT 0,10;TAB 31;""; 2530 GO SUB 1300: PRINT AT 21,8; PAPER 5;"INSERT OR END"; 2540 LET S$="INSERT (I)": LET T$=B$: LET CL=7: LET R=2: LET C=0: GO SUB 1000 2550 IF I$="P" OR I$="p" THEN GO TO 2540 2560 RETURN 2600 REM ***HOLD POSSIBLE*** 2610 GO SUB 1300: PRINT AT 21,2; PAPER 5;"INSERT, HOLD, PLAY OR END"; 2620 GO SUB 1500: RETURN 2700 REM *** NO HOLD POSSIBLE ** 2710 GO SUB 1300: PRINT AT 21,5; PAPER 5;"INSERT, PLAY OR END"; 2720 LET S$="???": LET T$=" ": LET CL=1: LET R=18: LET C=13: GO SUB 1000 2730 RETURN 2800 REM ** WHAT TO DO WITH WINNINGS ** 2810 GO SUB 1300 2820 IF HB THEN PRINT AT 21,7;"";: GO TO 2840 2830 PRINT AT 21,4; PAPER 5;"HOLD, "; 2840 PRINT ; PAPER 5;"GAMBLE OR COLLECT"; 2850 LET S$="???": LET T$=" ": LET CL=1: LET R=18: LET C=13: GO SUB 1000 2860 RETURN 2900 REM *** PLAY *** 2910 FOR I=1 TO 3: IF H(I) THEN GO TO 2940 2920 LET O(I)=V(I): LET FI=INT (RND*100)+1: LET V(I)=FI: IF FI<5 THEN GO TO 2940 2930 LET V(I)=5+(FI>7)+(FI>10)+(FI>13)+(FI>36)+(FI>49)+(FI>68)+(FI>87) 2940 NEXT I 2950 FOR C=6 TO 9: PRINT AT C,20;" ";: PRINT AT C+1,20; PAPER 2;" "; 2960 FOR I=1 TO 15: NEXT I: NEXT C 2970 FOR C=10 TO 7 STEP -1: PRINT AT C,20; PAPER 3;" ";: PRINT AT C-1,20; PAPER 2;" "; 2980 FOR I=1 TO 15: NEXT I: NEXT C 2990 FOR I=1 TO 3: LET F(I)=0: NEXT I 3000 FOR I=0 TO 70: FOR J=1 TO 3 3010 IF H(J)=1 THEN GO TO 3060 3020 IF F(J)=1 THEN GO TO 3050 3030 LET O(J)=O(J)+1: IF O(J)>13 THEN LET O(J)=1 3040 IF (I>10+13*J) AND O(J)=V(J) THEN LET F(J)=1: BEEP .02,8*J 3050 PRINT AT 9,P(J); PAPER 6;W$(O(J)); 3060 NEXT J: NEXT I: RETURN 3100 REM ** TAKE CARE OF JOKERS 3110 LET JO=0: FOR I=1 TO 3: LET V=V(I) 3120 IF V>4 THEN LET FV=V: GO TO 3150 3130 LET JW=1: LET JO=JO+1: IF C(V)>0 THEN GO TO 3150 3140 PRINT AT 7,D(V); PAPER 3;" ";: LET C(V)=20: LET NJ=NJ-1 3150 NEXT I: LET DO=(NJ=0): IF DO THEN LET DC=15: PRINT AT 6,11; PAPER 6;"DOUBLE!"; 3160 RETURN 3200 REM ** COMPUTE WINNINGS 3210 LET HV=5: GO TO (3220 AND JO=0)+(3250 AND JO=1)+(3220 AND JO=2)+(3270 AND JO=3) 3220 LET HV=FV 3230 GO TO 3270 3250 LET V(4)=15: LET JR=JW+1: LET JL=JW-1: IF JL=0 THEN LET JL=4 3260 LET HV=V(JR): IF V(JR)>V(JL) THEN LET HV=V(JL) 3270 FOR I=1 TO 3: LET K(I)=V(I): IF V(I)<5 THEN LET K(I)=HV 3280 NEXT I: IF K(1)<>K(2) OR K(2)<>K(3) THEN GO TO 3300 3290 IF J(K(1)) THEN LET JA=1: LET JC=15: GO SUB 1400 3300 LET W1=0: LET W2=0 3310 FOR I=1 TO 3: IF K(I)=13 THEN LET W1=W1+1 3320 NEXT I: LET NS=1+(K(1)=K(2))+(K(2)=K(3)): LET W2=R(NS,K(2)) 3330 LET WI=W2: IF W1>WI THEN LET WI=W1 3340 IF JA AND WI>0 AND WI<10 THEN LET WI=10 3350 IF DO THEN LET WI=2*WI 3360 RETURN 3400 REM ** GAMBLE ROUTINE 3410 LET DT=1: LET G(1)=2*WI: LET G(2)=0: LET G(3)=INT (3*WI/2): LET G(4)=INT (WI/2) 3420 LET NG=NG+1: GO SUB 1300: PRINT AT 21,12; PAPER 5;"STOP"; 3430 FOR I=1 TO 3: PRINT AT I,8; PAPER 6;" ";: NEXT I: REM 15* 3440 LET R=R+1: IF R>4 THEN LET R=1 3450 PRINT AT E(R,1),E(R,2); PAPER 6;G(R): BEEP .003,10+3*R 3460 IF I$<>"S" AND I$<>"s" THEN LET I$=INKEY$: GO TO 3480 3470 LET DT=(2+RND)*0.5*DT^1.3: IF DT>250 THEN LET DT=250 3475 FOR I=1 TO DT: NEXT I: IF DT>200 THEN GO TO 3490 3480 PRINT AT E(R,1),E(R,2); PAPER 6;" ";: GO TO 3440 3490 FOR I=1 TO 3: PRINT AT I,8;TAB 31;"";: NEXT I 3500 LET GW=GW+G(R)-WI: LET WI=G(R): RETURN 3600 REM *** END OF GAME *** 3610 CLS : PRINT : PRINT "AMOUNT OF MONEY": PRINT 3620 PRINT " PUT IN:";TAB 18;"$";: LET X=NI: GO SUB 3800 3630 PRINT " GOT BACK:";TAB 18;"$";: LET X=MO/4: GO SUB 3800 3640 PRINT " MAX AT ONE TIME: $";: LET X=MM/4: GO SUB 3800 3650 IF GW>=0 THEN PRINT " WON BY GAMBLING: $";: LET X=GW/4: GO SUB 3800 3660 IF GW<0 THEN PRINT " LOST BY GAMBLING:$";: LET X=-GW/4: GO SUB 3800 3670 PRINT : PRINT : PRINT "NUMBER OF HOLDS:";TAB 19;: LET X=NH: GO SUB 3900 3680 PRINT "NUMBER OF GAMBLES:";TAB 19;: LET X=NG: GO SUB 3900 3690 PRINT "NUMBER OF TURNS:";TAB 19;: LET X=NT: GO SUB 3900 3700 RETURN 3800 LET L=LEN STR$ X-LEN STR$ INT X 3810 LET X$=STR$ X+("0" AND L=2)+(".00" AND L=0) 3820 FOR I=LEN X$ TO 5: PRINT " ";: NEXT I: PRINT X$: RETURN 3900 FOR I=LEN STR$ X TO 2: PRINT " ";: NEXT I: PRINT X: RETURN 4000 REM *** MAIN PROGRAM *** 4010 GO SUB 2000: REM SCREEN 4020 GO SUB 2300: REM ADAPT 4030 LET CA=2*HB+(MO>1)+1: GO SUB (2500 AND CA=1)+(2600 AND CA=2)+(2500 AND CA=3)+(2700 AND CA=4) 4040 PRINT AT 3,8;TAB 31;"";: LET CA=(I$="I" OR I$="i")+2*(I$="P" OR I$="p")+3*(I$="E" OR I$="e") 4050 GO TO (4030 AND CA=0)+(4100 AND CA=1)+(4200 AND CA=2)+(4700 AND CA=3) 4100 LET NI=NI+1: LET IN=4: GO SUB 1100: IF MO>MM THEN LET MM=MO 4110 GO TO 4030 4200 LET IN=-2: GO SUB 1100 4210 GO SUB 2900: REM PLAY 4230 GO SUB 3100: REM JOKERS 4240 GO SUB 3200: REM WINNINGS 4250 IF H(1)+H(2)+H(3)>0 THEN GO TO 4270 4260 LET HB=0: LET LW=WI: GO TO (4290 AND WI>0)+(4020 AND WI<=0) 4270 LET HB=1: IF WI>LW THEN GO TO 4290 4275 IF LW=0 THEN GO TO 4020 4280 PRINT AT 3,10;TAB 31;"";: PRINT AT 3,11; PAPER 6;"YOU LOST";: BEEP 2,10: GO TO 4020 4290 PRINT AT 3,10; PAPER 6;"YOU WON ";WI;: FOR I=1 TO WI: BEEP .1,20: NEXT I 4300 IF MO<2 THEN LET HB=1 4310 GO SUB 2800: REM GET INSTRUCTIONS 4320 LET CA=((I$="H" OR I$="h") AND NOT HB)+2*(I$="G" OR I$="g")+3*(I$="C" OR I$="c") 4330 GO TO (4310 AND CA=0)+(4600 AND CA=1)+(4500 AND CA=2)+(4400 AND CA=3) 4400 LET IN=WI: GO SUB 1100: GO TO 4020 4500 LET HB=1: GO SUB 3400: REM GAMBLE 4510 IF WI>0 THEN GO TO 4290 4520 GO TO 4280 4600 LET WI=0: GO TO 4020 4700 GO SUB 3600: REM END 4800 STOP 9998 SAVE "las vegas" LINE 1 9999 PRINT "TO VERIFY - REWIND": VERIFY ""