This program implements a three-reel fruit machine (slot machine) simulation called “Las Vegas,” featuring jokers, a doubling bonus, a gamble feature, and detailed end-of-session statistics. The reels display symbols encoded in the string W$=”AKQJ7*$0/=+#%” and use a weighted random distribution at line 2930 to simulate real slot-machine probabilities, with higher-value symbols appearing less frequently. Payout rates are stored in the two-dimensional array R(3,13), covering single and triple matches, and joker symbols (values 1–4) act as wild cards, with special jackpot animations triggered by three matching jackpot symbols. A gamble sub-game at line 3400 spins through four prize values with an accelerating delay loop controlled by variable DT, slowing to a stop using a power-law formula. The program tracks coins inserted, maximum balance, holds taken, gambles made, and turns played, then formats monetary totals with two decimal places using STR$ arithmetic at lines 3800–3810.
Program Analysis
Program Structure
The program is organized into clearly delineated subroutines, each introduced by a REM comment. Execution begins at line 4000 after initialization at lines 100–240, which sets up all arrays, loads payout data, and seeds the reel positions. The main loop cycles through lines 4010–4600, calling subroutines for screen drawing, state adaptation, player input, reel spinning, joker resolution, winnings computation, and gambling.
| Line Range | Subroutine |
|---|---|
| 1000–1040 | Flash prompt and wait for INKEY$ |
| 1100–1130 | Animate money counter increment/decrement |
| 1200–1220 | Remove DOUBLE bonus state |
| 1300–1310 | Clear bottom line |
| 1400–1430 | Jackpot animation |
| 1500–1580 | Flash hold buttons and get hold input |
| 2000–2150 | Draw full screen layout |
| 2300–2410 | Adapt state variables between turns |
| 2500–2560 | Not enough money handler |
| 2600–2620 | Hold-possible input prompt |
| 2700–2730 | No-hold input prompt |
| 2800–2860 | Post-win options (hold/gamble/collect) |
| 2900–3060 | Reel spin animation and settlement |
| 3100–3160 | Joker detection and DOUBLE trigger |
| 3200–3360 | Winnings computation |
| 3400–3500 | Gamble sub-game |
| 3600–3700 | End-of-session statistics display |
| 3800–3820 | Format and print monetary value |
| 3900–3900 | Format and print integer value |
| 4000–4800 | Main program loop |
Weighted Reel Distribution
The core randomness at line 2930 maps a uniform 1–100 integer to a symbol index using a chain of Boolean comparisons:
LET V(I)=5+(FI>7)+(FI>10)+(FI>13)+(FI>36)+(FI>49)+(FI>68)+(FI>87)
This produces a stepped distribution where symbol 5 (index into W$) has the highest probability and higher-value symbols appear progressively less often. Values 1–4 are reserved for joker symbols and are reached only when FI<5 (a 4% chance per reel).
Computed GO TO Idiom
The program makes extensive use of computed GO TO and GO SUB by multiplying a target line number by a Boolean expression. For example:
GO TO (4030 AND CA=0)+(4100 AND CA=1)+(4200 AND CA=2)+(4700 AND CA=3)
Because AND returns the left operand when the right is non-zero and 0 otherwise, exactly one term evaluates to a non-zero line number and the rest to 0, dispatching to the correct branch. This avoids a chain of IF/GO TO statements and is a well-known BASIC optimization technique on this platform.
Joker and Wild Card Logic
Lines 3100–3160 scan the three settled reel values. Any V(I) in the range 1–4 is a joker; the code counts jokers in JO, records the joker’s reel position in JW, and marks the joker symbol’s slot as consumed for a cooldown period (C(V)=20) so it cannot immediately repeat. If all four joker slots are exhausted (NJ=0), the DOUBLE bonus activates for 15 turns.
Lines 3210–3270 then substitute a HV (highest value) for joker reels. For one joker, the program picks the better of its two neighbors; for two jokers, the single non-joker value is used; three jokers trigger only the jackpot path.
Gamble Sub-Game
The gamble routine at lines 3400–3500 cycles through four prize amounts stored in G(1..4): double winnings, zero, 1.5× winnings, and 0.5× winnings. A rotating display highlights each option in turn. Deceleration is implemented by the power-law formula:
LET DT=(2+RND)*0.5*DT^1.3
This causes the delay counter DT to grow super-linearly with each cycle, mimicking a spinning wheel slowing to a halt. Once DT exceeds 200 the loop exits and the currently highlighted prize is awarded. GW accumulates the net gain or loss across all gambles for the end-of-session report.
Money Formatting
The subroutine at lines 3800–3820 formats a monetary value (stored as integer quarter-coins, divided by 4 before display) to always show two decimal places. It uses STR$ and string concatenation with Boolean string expressions:
LET X$=STR$ X+("0" AND L=2)+(".00" AND L=0)
Here L is the difference between the total length of STR$ X and the length of its integer part. If L=0 there is no decimal point, so ".00" is appended; if L=2 there is only one decimal digit, so "0" is appended. Right-padding is then added with a FOR loop to achieve a consistent column width.
Screen Layout and Color Use
The screen is built entirely with PRINT AT and PAPER/INK/FLASH/OVER attribute controls—no machine code or UDGs are used. The fruit machine cabinet outline is drawn at lines 2010–2090 using colored spaces to create a visual frame. PAPER colors 1 (blue), 2 (red), 3 (magenta), 5 (cyan), and 6 (yellow) are used to distinguish different cabinet zones, reel windows, hold buttons, and the win tray.
State Variables
MO— current money in quarter-coinsMM— maximum money reached (for statistics)NI— number of coins insertedNT— number of turns playedNH— number of holds takenNG— number of gambles takenGW— net gain/loss from gamblingWI— current win amountHB— hold blocked flag (set when hold is unavailable)DO— DOUBLE active flag;DC— DOUBLE countdownJA— jackpot active flag;JC— jackpot display counterNJ— number of joker symbols remaining available
Notable Anomalies
At line 3210, the computed GO TO expression handles JO=0 and JO=2 identically (both branch to 3220), while JO=1 goes to 3250 and JO=3 goes to 3270. The case JO=2 correctly falls through to 3220 where FV (the last non-joker value set at line 3120) is used as HV, which is correct behavior for two jokers mirroring the one non-joker reel.
Line 2920 sets FI=INT(RND*100)+1 and then checks IF FI<5 to assign a joker, but also stores FI directly into V(I) before the check. This means joker reels (values 1–4) and the guard value for non-spin reels are both valid paths through the same assignment, with the weighted symbol computation on line 2930 only reached when FI>=5.
Source Code
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 ""
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

