Slot Machine

This file is part of and Timex Sinclair Public Domain Library Tape 1007. Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Gambling, Game

This program simulates a three-reel slot machine with fruit symbols (LEMON, ORANGE, PLUM, BELL, CHERRY) and a blank (BAR) outcome. Three independent random numbers A, B, and C (each in the range 1–20) determine which symbol appears on each reel, displayed inside a simple box drawn with block graphics at the centre of the screen. A payout table (lines 210–300) evaluates combinations and assigns a coin value to variable P, while a running total X tracks cumulative winnings after deducting one coin per spin as the cost of play. The spin display pauses for approximately 65 seconds (PAUSE 4E4) before looping back automatically.


Program Analysis

Program Structure

The program is divided into three logical phases that repeat in a loop:

  1. Initialisation (lines 5–8): Resets the running total X to zero and draws a static decorative border using block graphics.
  2. Reel evaluation (lines 10–200): Generates three random integers A, B, C (1–20) and maps them to symbol strings printed at fixed screen positions inside the border.
  3. Payout calculation and display (lines 205–350): Evaluates the combination against a hand-coded payout table, prints the result, updates the running balance, pauses, then jumps back to line 10.

Reel Symbol Mapping

Each reel uses its own range-check idiom. The mappings are as follows:

VariableRangeSymbol Printed
A (reel 1, col 5)< 7ORANGE
7BELL
8–10CHERRY
11–14PLUM
15, >15(blank)
B (reel 2, col 12)< 10BELL
10–12(blank)
13PLUM
14ORANGE
15(blank)
> 15CHERRY
C (reel 3, col 19)< 11LEMON
11–15ORANGE
16(blank/BAR)
17BELL
> 17PLUM

Payout Table

Lines 205–300 use cascading IF statements with LET P=0 initialised at line 205. Later matching conditions overwrite earlier ones, so the last matching rule wins. Selected payouts:

  • 200 coins — three blanks (lines 210: C=16, B=15, A=15)
  • 100 coins — two blanks and one other combination (line 220)
  • 18 coins — various mixed combinations (lines 230, 240, 300)
  • 14 coins — PLUM/PLUM/PLUM (line 290)
  • 10 coins — ORANGE/ORANGE/ORANGE (line 280), or other matches (line 250)
  • 5 coins — CHERRY on reel 1 and CHERRY on reel 2 (line 270)
  • 2 coins — CHERRY on reel 1 alone (line 260)

Economy Model

Line 320 deducts one coin per spin regardless of outcome (LET X=X+P-1), making the house edge implicit in the payout probabilities. The running total X can go negative, as there is no guard against it.

Notable Techniques

  • The border on rows 9–11 is drawn once at startup (lines 6–8) using block graphic characters, giving a persistent slot-machine window frame without redrawing each spin.
  • Each symbol string is padded to exactly 7 characters (e.g. " LEMON ", "CHERRY ") so that printing a new symbol always fully overwrites the previous one without needing to clear the cell first.
  • PAUSE 4E4 (line 350) uses floating-point scientific notation; 4×10⁴ = 40000 fiftieths-of-a-second ≈ 13 minutes, which is clearly unintentional — the programmer likely intended a short pause. This is a significant bug.
  • Lines 1410–1430 are dead code that is never reached due to the unconditional GOTO 10 at line 1400.

Bugs and Anomalies

  • PAUSE 4E4 bug: The pause at line 350 is approximately 800 seconds (over 13 minutes) rather than a brief display pause. A value of 100 or 200 would be more typical.
  • Overlapping payout rules: Lines 260 and 270 both trigger when A is in range 8–10 and B>15, so line 270 (P=5) always overrides line 260 (P=2) in that scenario, which appears intended.
  • Incomplete symbol coverage: Reel 3 value C=17 sets the symbol BELL (line 80) but no payout rule specifically rewards three BELLs as a triple match, making it a purely decorative outcome unless it falls into a broader range condition.
  • Initialisation at line 5: X is reset to zero only once at program start (line 5 runs before the loop begins at line 10), so winnings accumulate correctly across spins.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10294-10335.

Related Products

Related Articles

Related Content

Image Gallery

Slot Machine

Source Code

   5 LET X=0
   6 PRINT AT 9,4;"\:'\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\''\':"
   7 PRINT AT 10,4;"\:                      \ :"
   8 PRINT AT 11,4;"\:.\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\.:"
  10 LET A=INT (RND*20)+1
  20 LET B=INT (RND*20)+1
  30 LET C=INT (RND*20)+1
  40 IF C<11 THEN PRINT AT 10,19;" LEMON "
  50 IF C>10 AND C<16 THEN PRINT AT 10,19;"ORANGE "
  60 IF C>17 THEN PRINT AT 10,19;" PLUM  "
  70 IF C=16 THEN PRINT AT 10,19;"       "
  80 IF C=17 THEN PRINT AT 10,19;" BELL  "
  90 IF B<10 THEN PRINT AT 10,12;" BELL  "
 100 IF B>15 THEN PRINT AT 10,12;"CHERRY "
 110 IF B=15 THEN PRINT AT 10,12;"       "
 120 IF B=14 THEN PRINT AT 10,12;"ORANGE "
 130 IF B=13 THEN PRINT AT 10,12;" PLUM  "
 140 IF B<13 AND B>9 THEN PRINT AT 10,12;"       "
 150 IF A<7 THEN PRINT AT 10,5;"ORANGE "
 160 IF A>15 THEN PRINT AT 10,5;"       "
 170 IF A<15 AND A>10 THEN PRINT AT 10,5;" PLUM  "
 180 IF A<11 AND A>7 THEN PRINT AT 10,5;"CHERRY "
 190 IF A=15 THEN PRINT AT 10,5;"       "
 200 IF A=7 THEN PRINT AT 10,5;" BELL  "
 205 LET P=0
 210 IF C=16 AND B=15 AND A=15 THEN LET P=200
 220 IF C=16 AND B<13 AND B>9 AND A>15 THEN LET P=100
 230 IF C=16 AND B<10 AND A=7 THEN LET P=18
 240 IF C=16 AND B=13 AND A<15 THEN LET P=18
 250 IF C=16 AND B=14 AND A<7 THEN LET P=10
 260 IF A<11 AND A>7 THEN LET P=2
 270 IF A<11 AND A>7 AND B>15 THEN LET P=5
 280 IF A<7 AND B=14 AND C>10 AND C<16 THEN LET P=10
 290 IF A<15 AND B=13 AND C>17 AND A>10 THEN LET P=14
 300 IF A=7 AND B<10 AND C=17 THEN LET P=18
 310 PRINT AT 14,7;"PAYOFF IS ";P;" COINS "
 320 LET X=X+P-1
 330 PRINT AT 18,7;"WINNINGS ";X;"   "
 350 PAUSE 4E4
\n1400 GOTO 10
\n1410 CLEAR 
\n1420 SAVE "1032%5"
\n1430 RUN 

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

People

No people associated with this content.

Scroll to Top