Another Dice Game

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

This program implements a simplified dice game where the player bets on whether two rolled dice will total under 7, equal 7, or over 7. The player starts with a stake of $50 and wagers between $1 and $6 per round. A “7” bet pays 4-to-1 (net gain of 4× the wager), while under/over bets pay even money; a roll of 7 wipes out under/over bets, and a non-7 wipes out a “7” bet. The game ends automatically when the stake drops below $1 or the player presses “S” to stop. Lines 340–360 form a loader stub that clears memory, saves the program with an auto-run flag, and then runs it.


Program Analysis

Program Structure

The program is organised into a main loop and a single subroutine:

  1. Initialisation (line 20): Sets the starting stake M to 50.
  2. Bet entry (lines 30–70): Displays the current stake via GOSUB 320, prints the betting options, and accepts a choice in A$.
  3. Amount entry (lines 90–120): Prompts for a wager A in the range 1–6, looping back on invalid input.
  4. Dice roll (lines 130–180): Generates two random dice values B and C, prints them along with their sum D.
  5. Win/loss calculation (lines 190–230): Four conditional assignments determine winnings W, then updates the stake.
  6. Result display and loop (lines 240–310): Prints outcome, refreshes the stake display, delays with a FOR loop, checks for bankruptcy, clears the screen, and repeats.
  7. Stake subroutine (lines 320–330): Prints the current stake at a fixed screen position and returns.
  8. Loader stub (lines 340–360): CLEAR, SAVE with auto-run, and RUN — never reached during normal play.

Betting Logic

The payout structure is encoded across lines 190–220:

ConditionNet change to stake (W)
D=7 and bet "B"+4*A (4-to-1 payout)
D<7 and bet "A"+A (even money)
D>7 and bet "C"+A (even money)
Incorrect guess (any)-A

Note that line 220 uses a compound boolean expression to catch all losing scenarios in a single statement, covering both “7” bets that didn’t land on 7 and under/over bets that landed exactly on 7.

Key BASIC Idioms

  • Dice simulation: INT(RND*6)+1 produces a uniform integer in the range 1–6, applied twice for two independent dice.
  • Input validation loop: Line 110 uses IF A<1 OR A>6 THEN GOTO 100 to re-prompt without a structured loop construct.
  • Soft delay: Lines 270–280 use a FOR/NEXT loop with no body as a timing delay — a classic technique on machines without a reliable PAUSE in all contexts.
  • Trailing spaces in PRINT: Line 320 appends " " after printing the stake value to erase any leftover wider digits from a previous display.

Bugs and Anomalies

  • Uninitialised W: If A$ is neither "A", "B", nor "C" (for example an accidental keypress), none of lines 190–220 will set W, so the previous round’s value persists and corrupts the stake. There is no explicit initialisation of W at the top of the loop.
  • Line 80 exit only before betting: The “S to stop” check occurs only at bet-selection time; there is no escape during amount entry or after a round.
  • Stake display on first run: GOSUB 320 at line 30 is called before any bet or win/loss, so M is displayed correctly from the start — this is intentional and correct.
  • Loader stub unreachable: Lines 340–360 cannot be reached through normal GOTO/GOSUB flow; they exist solely to be executed manually or as part of a distribution workflow.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10252 – 10293.

Related Products

Related Articles

Related Content

Image Gallery

Another Dice Game

Source Code

  20 LET M=50
  30 GOSUB 320
  40 PRINT AT 4,3;"PLACE YOUR BET"
  50 PRINT AT 10,0;"(A) UNDER 7   (B) 7   (C) OVER 7"
  60 PRINT AT 11,5;"EVEN   5 FOR 1   EVEN"
  70 INPUT A$
  80 IF A$="S" THEN STOP  
  90 PRINT AT 16,10;"AMOUNT ?"
 100 INPUT A
 110 IF A<1 OR A>6 THEN GOTO 100
 120 PRINT AT 16,10;"  OK $";A
 130 LET B=INT (RND*6)+1
 140 PRINT AT 13,3;B;TAB 10;
 150 LET C=INT (RND*6)+1
 160 PRINT C;TAB 6;
 170 LET D=C+B
 180 PRINT D
 190 IF D=7 AND A$="B" THEN LET W=4*A
 200 IF D<7 AND A$="A" THEN LET W=A
 210 IF D>7 AND A$="C" THEN LET W=A
 220 IF ((A$="A" OR A$="C") AND D=7) OR (A$="B" AND D<>7) THEN LET W=-A
 230 LET M=M+W
 240 IF W>0 THEN PRINT AT 16,4;"YOU WIN $";W
 250 IF W<0 THEN PRINT AT 16,4;"YOU LOSE $";-W
 260 GOSUB 320
 270 FOR N=1 TO 60
 280 NEXT N
 290 IF M<1 THEN STOP 
 300 CLS 
 310 GOTO 30
 320 PRINT AT 2,12;"STAKE $";M;"  "
 330 RETURN 
 340 CLEAR 
 350 SAVE "1029%3"
 360 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