Slot Machine

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

This program implements a text-based slot machine game using block graphics characters to draw the reels. The player bets between $1 and $5 per spin, with winnings multiplied by a payout factor that depends on which symbols align. Two constants, E=2 and F=3, are used throughout as arithmetic building blocks to encode key values (e.g., E-E=0, F-E=1, E+F=5, D=20, D*D=400, D+D=40) rather than using those literals directly. The slot reel subroutine at line 400 picks a random value from 0–4, loops briefly (possibly for a spin animation delay), then prints a block-graphic character using CHR$(128+A*2). Payout logic awards a multiplier of 2 for a partial match involving symbol 3, 5 for three-of-a-kind with symbol 3, and 20 for any other three-of-a-kind.


Program Analysis

Program Structure

The program is organized into three logical sections:

  1. Initialization (lines 1–45): Sets up constants, displays title, randomizes, shows a lucky/unlucky message, and initializes the money variable.
  2. Main game loop (lines 50–320): Prompts for a bet, draws the slot machine frame, calls the reel subroutine three times, evaluates the result, and applies winnings.
  3. Reel subroutine (lines 400–440): Picks a random symbol, performs a short FOR loop (possibly for timing), and prints a block graphic character.

Constant Encoding with E and F

Rather than using numeric literals, the program defines E=2 and F=3 at lines 5–10 and then builds all needed values from arithmetic on these two constants. This is a well-known memory-saving idiom on Sinclair machines, where storing a small integer in a variable and reusing it can be more compact than repeating multi-digit numeric tokens.

ExpressionValueUsed for
E-E0Zero / AT row 0 / loop start
F-E1Minimum bet check, condition threshold
E2Column offset, multiplier in CHR$ calculation
F3Symbol number for special payout
E+F5Maximum bet
D20Line number target, maximum payout multiplier
D*F60GOTO target for invalid bet (line 60 = INPUT)
D*D400GOSUB target = reel subroutine
D/E10TAB column for third reel
D+D40GOTO target line 40 (start of next round)

Slot Machine Frame

Lines 80–130 draw a simple three-reel frame using block graphic characters. Line 80 uses \''\''\'' sequences (▀ top-half block) for the top border of each reel, and line 100 uses \..\..\..) sequences (▄ bottom-half block) for the bottom border. The middle row (line 90) is blank spaces padded with % column separators, leaving room for the reel symbols to be printed by the subroutine calls.

Reel Subroutine (Lines 400–440)

The subroutine at line 400 generates a random integer A in the range 0–4 via INT(RND*(E*F)) — i.e., INT(RND*6), giving values 0–5, though only 0–4 are meaningful given the five block graphic characters starting at CHR$(128). The FOR Z=0 TO 15 loop at lines 410–420 introduces a brief delay to simulate spinning. Line 430 prints CHR$(128+A*2), selecting every other block graphic from the set at character codes 128, 130, 132, 134, 136.

Payout Logic

Lines 250–310 handle the win condition and payout multiplier:

  • If X (first reel) is not symbol 3 (F), AND not all three reels match, the game jumps to line 20 (next round, no win).
  • Default multiplier C=2 (line 270) — a partial win when X=3.
  • If the second reel Y=3, multiplier becomes C=5 (line 280).
  • If all three reels match (X=Y=Z), multiplier becomes C=20 (line 290).
  • Winnings paid = C*B added to running total M.

Notable Bugs and Anomalies

  • Win condition logic (line 250): The condition IF X<>F THEN IF X<>Y OR X<>Z THEN GOTO D is ambiguous. It skips the win if X is not 3 AND (X≠Y or X≠Z), meaning a non-symbol-3 three-of-a-kind can still reach the win block only if X=Y=Z, but the inner OR makes it hard to win with other symbols. In practice, any non-3 three-of-a-kind slips through because both conditions are false when X=Y=Z.
  • RND range (line 400): INT(RND*(E*F)) = INT(RND*6) can produce 0–5, giving six possible values, but the payout code only specially handles symbol F=3. Symbol 5 would display CHR$(138) and could still match for the generic three-of-a-kind payout.
  • TAB column line 170: PRINT TAB E*F; = TAB 6 for the second reel position. Combined with the AT on line 140 (AT F-E,E = AT 1,2), this sequences the three reel outputs horizontally across row 1.
  • Line 460 RUN: After SAVE, a bare RUN restarts the program, which is normal for a SAVE/autostart pattern.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10122 – 10175.

Related Products

Related Articles

Related Content

Image Gallery

Slot Machine

Source Code

   1 PRINT AT 0,14;"SLOT MACHINE"
   5 LET E=2
  10 LET F=3
  15 LET M=E-E
  20 RAND 
  25 LET D=RND*E
  30 IF D>=F-E THEN PRINT "TRY YOUR LUCK"
  35 IF D<F-E THEN PRINT "PAY ME TO WIN"
  40 LET D=20
  45 PRINT "NOW AT $";M
  50 PRINT "PLAY $1 TO $5"
  60 INPUT B
  70 IF B<F-E OR B>E+F THEN GOTO D*F
  80 PRINT AT E-E,E-E;"% \''\''\''% \''\''\''% \''\''\''% "
  90 PRINT "%    %    %    % "
 100 PRINT "% \..\..\..% \..\..\..% \..\..\..% "
 110 PRINT "             "
 120 PRINT "             "
 130 PRINT "             "
 140 PRINT AT F-E,E;
 150 GOSUB D*D
 160 LET X=A
 170 PRINT TAB E*F;
 180 GOSUB D*D
 190 LET Y=A
 200 PRINT TAB D/E;
 210 GOSUB D*D
 220 LET Z=A
 230 PRINT AT F,E-E;
 240 LET M=M-B
 250 IF X<>F THEN IF X<>Y OR X<>Z THEN GOTO D
 260 PRINT "YOU WIN $";
 270 LET C=E
 280 IF Y=F THEN LET C=E+F
 290 IF X=Y AND X=Z THEN LET C=D
 300 LET M=M+C*B
 310 PRINT C*B
 320 GOTO D+D
 400 LET A=INT (RND*(E*F))
 410 FOR Z=E-E TO 15
 420 NEXT Z
 430 PRINT CHR$ (128+A*E);
 440 RETURN 
 450 SAVE "1015%2"
 460 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