Inducto

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

INDUCTO is a number-guessing game that picks a secret integer between 1 and 20 and gives the player up to 10 attempts to identify it. After each wrong guess, instead of a simple “higher/lower” hint, the program reveals the square root of the absolute difference between the guess and the target, providing a scaled numeric clue. Line 20 uses a RND>RND comparison to introduce a probabilistic bias, giving a roughly 50% chance of re-rolling the target before play begins. The SCROLL command is used throughout to manage the limited display, keeping output readable on the small screen.


Program Analysis

Program Structure

The program is compact at 13 executable lines. Control flow is straightforward: a setup phase (lines 10–20), a guessing loop (lines 30–100), and a resolution phase (lines 110–150).

  1. Lines 10–20: Generate the secret number A as a random integer 1–20. Line 20 re-rolls with roughly 50% probability.
  2. Lines 30–100: A FOR loop over up to 10 guesses. Each iteration scrolls, prompts, reads input, and either branches to the win condition or prints a clue.
  3. Lines 110–150: Print the answer, detect win vs. loss, and display the win message or STOP.
  4. Lines 160–170: SAVE followed by RUN for tape storage and restart.

The RND>RND Re-roll (Line 20)

Line 20 reads IF RND>RND THEN GOTO 10. Because two independent RND calls are evaluated, there is approximately a 50% chance of looping back to re-generate A. This does not produce a uniform distribution over iterations — it simply adds a non-deterministic delay before play starts, and the final value of A is still uniformly drawn from 1–20. It does not improve randomness in any meaningful way but is a common idiom seen in early BASIC games.

The Clue Mechanic

Line 90 is the most distinctive feature of the game:

PRINT "WRONG ";C,"CLUE- ";SQR(ABS(A-C))

Rather than a binary higher/lower hint, the player receives SQR(ABS(A-C)) — the square root of the absolute difference. For a range of 1–20, the maximum possible raw difference is 19, giving a maximum clue of approximately 4.36. This compresses the hint into a non-linear scale, making nearby misses hard to distinguish from each other (e.g., a difference of 1 yields clue 1.0, while a difference of 4 yields only 2.0), which increases difficulty compared to a direct difference hint.

Win/Loss Detection

When the correct answer is entered, line 80 jumps to line 110, bypassing NEXT B. At line 130, the condition C<>A catches the case where the loop exhausted all 10 guesses without a correct answer — in that path C still holds the last (wrong) guess, so STOP is executed. If the player won, C=A and execution falls through to line 140, which prints the congratulatory message including B, the guess number on which they succeeded. Note the deliberate zero in "W0W" (digit zero, not letter O) — a common typographical quirk in early BASIC listings.

Display Management

SCROLL is called at lines 40, 70, and 110 to advance the display before printing, preventing the “scroll?” prompt from interrupting gameplay on the ZX81’s 24-line limit.

Notable Anomalies

  • Line 120 ends with a trailing comma: PRINT A,. This positions the cursor at the next print zone rather than a new line, so the win message on line 140 prints on the same line as the revealed answer — a minor layout quirk.
  • In the loss path (loop exhausted), A is printed at line 120 but the player’s last guess C is not re-displayed, which is slightly inconsistent with the win path where B is shown.
  • The RND>RND idiom at line 20 is probabilistically inelegant; a simple GOTO 10 with no condition, or no re-roll at all, would be functionally equivalent for randomness quality.

Variable Summary

VariablePurpose
AThe secret target number (1–20)
BCurrent guess number (loop counter, 1–10)
CPlayer’s current guess (INPUT)

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10211 – 10251.

Related Products

Related Articles

Related Content

Image Gallery

Inducto

Source Code

   5 REM "INDUCTO"
  10 LET A=INT (RND*20)+1
  20 IF RND>RND THEN GOTO 10
  30 FOR B=1 TO 10
  40 SCROLL 
  50 PRINT "GUESS NO. ";B
  60 INPUT C
  70 SCROLL 
  80 IF C=A THEN GOTO 110
  90 PRINT "WRONG ";C,"CLUE- ";SQR (ABS (A-C))
 100 NEXT B
 110 SCROLL 
 120 PRINT A,
 130 IF C<>A THEN STOP 
 140 PRINT "W0W,YOU GOT IT MAN";B
 150 STOP 
 160 SAVE "1022%6"
 170 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