This program simulates a game of Russian Roulette, presenting the player with a six-shot pistol containing one bullet and challenging them to pull the trigger ten times. The core mechanic uses a single RND call (line 105) to generate a floating-point value, comparing it against 5/6 to determine whether the chamber is empty or loaded. When the chamber is safe, a secondary RND call (line 195) randomly selects between printing “CLICK” or “EMPTY CHAMBER” as feedback. A quirk exists at line 120: because a continuous RND value will essentially never equal exactly 5/6, the “BANG” branch is unreachable for G exactly equal to 5/6, creating a near-zero but not strictly zero probability of an unhandled case between the two IF conditions. The “COWARD” and “BANG” outcomes both use infinite GOTO loops to display their messages repeatedly.
Program Analysis
Program Structure
The program is divided into clear functional blocks:
- Lines 10–50: Title, rules display, and initial Y/N prompt
- Lines 55–135: Main game loop — ten trigger pulls with RND-based outcome branching
- Lines 140–180: Survival message and play-again prompt
- Lines 185–190: “Coward” infinite loop for players who decline
- Lines 195–215: Subroutine for safe-chamber feedback (CLICK or EMPTY CHAMBER)
- Lines 220–225: “BANG” infinite loop for the fatal outcome
- Lines 300–400: SAVE and auto-RUN tail
Core Probability Mechanic
The one-in-six chance is implemented at line 105 by drawing a uniform random value G=RND (in the range 0 to 1) and comparing it to the fraction 5/6 (≈0.8333). Line 115 routes a safe pull (G<5/6) to the subroutine at 195, while line 120 routes a fatal pull (G>5/6) to the BANG loop at 220. This gives approximately an 83.3% chance of safety and a 16.7% chance of firing — slightly worse odds than the real game’s 1-in-6 (16.7%), which happens to be correct here.
Notable Bugs and Anomalies
- Gap at G = 5/6 exactly: Neither condition at lines 115 nor 120 is satisfied when
Gequals exactly5/6. In this case execution falls through to line 125, treating the shot as a survivable miss. In practice, a floating-point RND hit of exactly 5/6 is vanishingly rare but theoretically possible. - Line 135 unreachable:
CLSat line 135 is never executed. WhenJ=10, line 125 sends control to 140, completely bypassing line 135. - Typo in line 160: “S FO STOP” should read “S FOR STOP” — a missing ‘R’.
- Missing CLS on new game: When the player chooses “G” to play again (line 180), control jumps to line 55 which resets
Jand callsRANDbut does not clear the screen before returning to the fire loop. - No validation on B$ input: If the player enters anything other than “G” at line 165, neither branch at 180 nor line 185 is reached cleanly — execution falls off the end of the listed code.
Key BASIC Idioms
| Line | Idiom | Purpose |
|---|---|---|
| 60 | RAND | Seeds the random number generator for unpredictable play |
| 105 | LET G=RND | Single RND draw reused for both outcome comparisons |
| 195 | LET H=INT(2*RND)+1 | Classic 1-or-2 integer RND idiom for binary choice |
| 185/220 | GOTO self | Infinite message loop — common in early BASIC game endings |
| 110 | PRINT , | Tab-separated PRINT to centre output on screen |
Subroutine Design
The safe-chamber subroutine (lines 195–215) uses a second RND call to choose between two responses: CLICK (H=1) and EMPTY CHAMBER (H=2). This adds variety to otherwise repetitive safe pulls. The RETURN at line 215 sends control back to line 125 to check whether ten shots have been fired.
Inverse Video and String Literals
Line 220 uses inverse-video characters (%B%A%N%G%.%.%.) to display “BANG…” in inverse video, making the fatal outcome visually distinctive on screen. The trailing semicolon suppresses the newline so repeated GOTO loops stack the text continuously across the display.
Content
Source Code
10 PRINT "RUSSIAN ROULETT"
20 PRINT
25 PRINT "HI GUN TOTER. YOU HAVE"
30 PRINT "A PISTOL WITH ONE BULLET IN IT"
35 PRINT "YOU WILL SPIN THE CHAMBER"
40 PRINT "AND FIRE 10 TIMES"
45 PRINT "ARE YOU GAME TO PLAY?(Y OR N)"
50 INPUT A$
55 LET J=0
60 RAND
65 IF A$="N" THEN GOTO 185
70 PRINT "PRESS ENTER TO FIRE"
75 INPUT T$
80 CLS
85 PRINT
90 PRINT
95 PRINT
100 LET J=J+1
105 LET G=RND
110 PRINT ,"SHOT NUMBER ";J
115 IF G<5/6 THEN GOSUB 195
120 IF G>5/6 THEN GOTO 220
125 IF J=10 THEN GOTO 140
130 IF J<10 THEN GOTO 70
135 CLS
140 PRINT
145 PRINT
150 PRINT ,"YOU HAVE SURVIVED."
155 PRINT "IF YOU WANT TO RISK DEATH AGAIN"
160 PRINT "PRESS G FOR GO OR S FO STOP"
165 INPUT B$
170 CLS
180 IF B$="G" THEN GOTO 55
185 PRINT "COWARD... ";
190 GOTO 185
195 LET H=INT (2*RND)+1
200 IF H=1 THEN PRINT "/.CLICK/."
210 IF H=2 THEN PRINT "EMPTY CHAMBER"
215 RETURN
220 PRINT "%B%A%N%G%.%.%.";
225 GOTO 220
300 SAVE "1004%6"
400 RUN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
