This program implements a slot machine (one-armed bandit) simulation with a graphical display drawn entirely in BASIC using block graphics characters. The machine tracks a running fund starting at $100, deducting $1 per pull and paying out between $2 and $200 depending on the reel combination. Three virtual reels are generated using RND with different range moduli (20, 23, and 23), giving each reel a distinct probability distribution across seven symbol types: asterisk, cherry (O), bar, double-bar, diamond, bell (BAR), and 7. The payout logic uses cascading IF statements to assign a win value W, with W=-1 representing a loss, and a coin-animation sequence simulates the handle pull using FOR/NEXT delay loops. The display features a decorative slot machine cabinet drawn with block graphics, a scrolling dollar-sign payout animation for wins, and the game ends when funds reach zero.
Program Analysis
Program Structure
The program is divided into clearly separated functional blocks:
- Lines 1–220: Screen setup — draws the slot machine cabinet and payout table using block graphics, then sets initial loss flag
W=-1. - Lines 229–310: Switches to SLOW mode, sets starting funds
M=100, and jumps to line 1410 to display the initial fund before entering the main loop. - Lines 400–440: “INSERT COIN” prompt loop, waiting for the player to press
C. - Lines 500–580: Coin insertion animation — bounces an “O” character around the screen using short FOR/NEXT delay loops.
- Lines 600–640: “PULL HANDLE” prompt loop, waiting for
Pkeypress. - Lines 700–760: Reel spin animation — prints scrolling bar graphics across the slot window.
- Lines 800–1050: Reel result generation using
RNDand cascading IF statements for each of three reels. - Lines 1100–1210: Win detection — compares
A$,B$,C$against known winning combinations and assigns payout toW. - Lines 1300–1340: Displays the three reel results on screen.
- Lines 1400–1720: Handles payout display, fund update, win animation, game-over check, and loops back to line 400.
- Lines 1730–1750: Dead code —
CLEAR,SAVE, andRUNare unreachable from normal game flow.
Reel Symbol Generation
Each reel uses a different integer range and a cascade of overwriting IF assignments to map a random number to a symbol string. Because each IF can overwrite a prior assignment, the effective probability of each symbol depends on how many integer values map to it after all comparisons are applied:
| Symbol | Reel 1 (R1, 1–20) | Reel 2 (R2, 1–23) | Reel 3 (R3, 1–23) |
|---|---|---|---|
| BAR (%B) | 20 only (1/20) | 23 only (1/23) | 23 only (1/23) |
| Bar-Bar (\ .\:.) | 18–19 (2/20) | 20–22 (3/23) | 17–18 (2/23) |
| 7 | 17 only (1/20) | 20 only (1/23) | 9–16 (8/23) |
| Asterisk (*) | 15–16 (2/20) | 15–19 (5/23) | — (0) |
| Double-bar (\,,) | 8–14 (7/20) | 9–14 (6/23) | 8 only (1/23) |
| Diamond (\.’) | 6–7 (2/20) | 6–8 (3/23) | 5–7 (3/23) |
| Cherry (O) | 1–5 (5/20) | 1–5 (5/23) | 1–4 (4/23) |
Note that reel 3 has no asterisk symbol, making any asterisk-based win dependent solely on reels 1 and 2, consistent with the payout table which only awards for one or two asterisks.
Payout Logic and Win Flag
The win variable W is initialised to -1 (loss) at line 1100. Each subsequent IF statement can only increase W; there is no guard against multiple matches since the combinations are mutually exclusive by construction. The fund update at line 1405 adds W directly: a loss subtracts 1 (the implied cost of a pull), while a win adds the net prize value minus the implicit $1 cost already deducted.
Key BASIC Idioms and Techniques
- Block graphics in strings: Symbol names like
\ .\:.,\,,, and\.'are zmakebas escape sequences for block graphic characters embedded directly in string literals and in PRINT statements, giving the display a graphical slot machine appearance without machine code. - TAB reuse in PRINT: Multiple
TABcalls within a single PRINT statement efficiently position both the graphic border and the payout description on the same line (e.g., line 20). - FOR/NEXT as delay: Empty FOR/NEXT loops (e.g., lines 505–506, 550–551) serve as timing delays for the coin animation. Longer delays use 50 iterations (line 1560).
- FAST/SLOW mode switching: Line 1 uses
FASTfor rapid screen drawing of the machine cabinet, then line 229 switches toSLOWfor normal display during gameplay. - Cascading IF for symbol selection: Rather than arrays or DATA statements, symbol probabilities are implemented as a chain of IF/LET overrides, a common space-saving technique.
- Win animation: Lines 1500–1610 animate dollar signs cascading down and then restoring the background, simulating coins dropping out of the machine.
Bugs and Anomalies
- FOR loop without NEXT (line 1420): Line 1420 opens a FOR loop (
FOR P=1 TO 10) but there is no corresponding NEXT statement. In ZX81 BASIC the interpreter will execute the body of the loop once and then fall through without error if no NEXT is encountered before the end of the program flow reaches a GOTO — effectively making this a no-op delay that never iterates. This is almost certainly a bug where the NEXT was accidentally omitted. - R1 unused from line 405: Line 405 sets
R1=RNDbefore the coin prompt, but R1 is overwritten unconditionally at line 800. This early assignment has no effect on gameplay. - Reel 3 can produce “£” symbol: Line 995 assigns
C$=" £"forR3<23(22 out of 23 values), but this symbol does not appear in any win-detection condition and is not listed on the payout table. It acts as a guaranteed loss symbol for most of reel 3’s range before being overwritten by subsequent IFs — only values 19–22 (4 values) actually resolve to “£” after all overrides, making it a hidden “near-miss” filler symbol. - Lines 1730–1750 are unreachable: After line 1720 (
GOTO 400), lines 1730–1750 can never execute during normal play; they appear to be leftover development artifacts.
Content
Source Code
1 FAST
10 PRINT AT 0,17;"JACKPOT PAYOFFS"
20 PRINT AT 1,7;"......";TAB 18;"* - - PAYS $2"
30 PRINT AT 2,7;"% ##% ";TAB 18;"* * - PAYS $5"
40 PRINT AT 3,1;".:% % % % % % % % ";TAB 18;"O O %B PAYS $10"
50 PRINT AT 4,0;".:% % %L%U%C%K%Y% % % ";TAB 18;"O O O PAYS $10"
60 PRINT AT 5,0;"% % % % % %7% % % % % :% : ";TAB 18;",, ,, %B PAYS $14"
70 PRINT AT 6,0;"% % % % % % % % % % % % ";TAB 18;",, ,, ,, PAYS $14"
80 PRINT AT 7,0;"% % ";TAB 9;"% % % ";TAB 17;" .:. .:. %B PAYS $18"
90 PRINT AT 8,0;"% % ";TAB 9;"% % % ";TAB 17;" .:. .:. .:. PAYS $18"
100 PRINT AT 9,0;"% % ";TAB 9;"% % % ";TAB 18;".' .' %B PAYS$100"
110 PRINT AT 10,0;"% % % % % % % % % % % % ";TAB 18;".' .' .' PAYS$100"
120 PRINT AT 11,0;"% % % % % % % % % % % % ";TAB 18;"%B %B %B PAYS$100"
130 PRINT AT 12,0;"% % % % % % % % % % % % ";TAB 18;"7 7 7 PAYS$200"
140 PRINT AT 13,0;"% % % $$$$$% % % ..% "
150 PRINT AT 14,0;"% % % $$$$$% % % "
160 PRINT AT 15,0;"% % % $$$$$% % % "
170 PRINT AT 16,0;"% % % % % % % % % % % "
180 PRINT AT 17,0;"% % % % % % % % % % % "
190 PRINT AT 18,0;"% % % ' '% % % "
200 PRINT AT 19,0;"% % % % % % "
210 PRINT AT 20,0;"':% % % % % % % % % :'"
220 LET W=-1
229 SLOW
300 LET M=100
310 GOTO 1410
400 PRINT AT 15,18;"INSERT COIN"
405 LET R1=RND
410 LET Q$=INKEY$
420 IF Q$="C" THEN GOTO 500
430 PRINT AT 15,18;" "
440 GOTO 400
500 PRINT AT 0,11;"O"
505 FOR P=1 TO 10
506 NEXT P
510 PRINT AT 1,10;"O"
520 PRINT AT 0,11;" "
525 FOR P=1 TO 10
526 NEXT P
530 PRINT AT 1,10;" "
540 PRINT AT 2,8;"O"
550 FOR P=1 TO 5
551 NEXT P
560 PRINT AT 2,9;"% "
570 FOR P=1 TO 5
571 NEXT P
580 PRINT AT 2,8;"@@"
600 PRINT AT 15,18;"PULL HANDLE"
610 LET Q$=INKEY$
615 PRINT AT 15,18;" "
620 IF Q$="P" THEN GOTO 700
640 GOTO 600
700 FOR I=1 TO 8
710 PRINT AT 3+I,11;" ";TAB 11;" :% : "
720 NEXT I
730 PRINT AT 7,3;"@@ @@ @@";TAB 3;"@@ @@ @@";TAB 3;"@@ @@ @@"
740 FOR I=1 TO 7
750 PRINT AT 12-I,11;" :% : ";TAB 11;" % "
760 NEXT I
800 LET R1=INT (20*RND)+1
810 LET R2=INT (23*RND)+1
820 LET R3=INT (23*RND)+1
850 LET A$=" %B"
860 IF R1<19 THEN LET A$=" .:."
870 IF R1=17 THEN LET A$=" 7"
880 IF R1<17 THEN LET A$=" *"
890 IF R1<15 THEN LET A$=" ,,"
900 IF R1<8 THEN LET A$=" .'"
910 IF R1<6 THEN LET A$=" O"
920 LET B$=" %B"
925 IF R2<23 THEN LET B$=" .'"
930 IF R2<20 THEN LET B$=" .:."
935 IF R2=20 THEN LET B$=" 7"
940 IF R2<15 THEN LET B$=" *"
950 IF R2<9 THEN LET B$=" ,,"
960 IF R2<6 THEN LET B$=" O"
990 LET C$=" %B"
995 IF R3<23 THEN LET C$=" £"
997 IF R3<19 THEN LET C$=" .'"
1000 IF R3<17 THEN LET C$=" .:."
1010 IF R3<9 THEN LET C$=" 7"
1020 IF R3<8 THEN LET C$=" ,,"
1050 IF R3<5 THEN LET C$=" O"
1100 LET W=-1
1105 IF A$=" *" THEN LET W=2
1110 IF A$=" *" AND B$=" *" THEN LET W=5
1120 IF A$=" O" AND B$=" O" AND C$=" %B" THEN LET W=10
1130 IF A$=" O" AND B$=" O" AND C$=" O" THEN LET W=10
1140 IF A$=" ,," AND B$=" ,," AND C$=" %B" THEN LET W=14
1150 IF A$=" ,," AND B$=" ,," AND C$=" ,," THEN LET W=14
1160 IF A$=" .:." AND B$=" .:." AND C$=" %B" THEN LET W=18
1170 IF A$=" .:." AND B$=" .:." AND C$=" .:." THEN LET W=18
1180 IF A$=" .'" AND B$=" .'" AND C$=" %B" THEN LET W=100
1190 IF A$=" .'" AND B$=" .'" AND C$=" .'" THEN LET W=100
1200 IF A$=" %B" AND B$=" %B" AND C$=" %B" THEN LET W=100
1210 IF A$=" 7" AND B$=" 7" AND C$=" 7" THEN LET W=200
1300 PRINT AT 7,2;" ";TAB 2;A$;TAB 2;" "
1310 FOR P=1 TO 10
1311 NEXT P
1320 PRINT AT 7,4;" ";TAB 4;B$;TAB 4;" "
1330 FOR P=1 TO 10
1331 NEXT P
1340 PRINT AT 7,6;" ";TAB 6;C$;TAB 6;" "
1400 IF W>0 THEN PRINT AT 15,18;"***WINNER***";TAB 23;"$";W
1405 LET M=M+W
1410 PRINT AT 18,18;"PRESENT FUNDS:";TAB 21;"$";M;" "
1415 IF W=-1 THEN GOTO 1700
1420 FOR P=1 TO 10
1500 PRINT AT 13,3;" "
1510 PRINT AT 19,3;"$$$$$"
1520 PRINT AT 14,3;" "
1530 PRINT AT 20,2;"$$$$$$$"
1540 PRINT AT 15,3;" "
1550 PRINT AT 21,1;"$$$$$$$$$"
1560 FOR P=1 TO 50
1561 NEXT P
1570 PRINT AT 19,3;" ";TAB 2;"% % % % % % % % % ";TAB 1;" "
1580 FOR I=13 TO 15
1590 PRINT AT I,3;"$$$$$"
1600 NEXT I
1610 PRINT AT 16,23;" "
1700 IF M=0 THEN PRINT AT 15,16;"OUT OF MONEY";TAB 19;"GAME OVER"
1710 IF M=0 THEN STOP
1720 GOTO 400
1730 CLEAR
1740 SAVE "1030%0"
1750 RUN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
