Skip to content

BASIC Computer Games (1978, Microcomputer Edition, David H. Ahl)

Author(s): Edited by David H. Ahl; program conversion by Steve North; illustrations by George Beker. Individual games by named contributors (Ray Westergard, Jim Storer, Robert Leedom, and others). Sources: The book itself (Workman Publishing / Creative Computing, 1978, ISBN 0-89480-052-3), read from a scan of the print edition. Line-number citations refer to the printed listings. Category: inspiration, Batch 12 (BASIC-listing corpus mining). Seventeen games read in full for mechanics and algorithms. Cross-cutting cart mapping lives in ../synthesis-basic-games.md. Serves: runtime / engineering (assigned by Josh; see cart map)

BASIC Computer Games is the book that put working game source into the hands of a generation of home-computer owners. Every entry is complete and self-contained: a page of prose explaining the game and crediting its author, the full BASIC listing, and a sample run showing exactly what the teletype printed. The programs were written across a ten-year span by a wide cross-section of people on timesharing systems (DEC RSTS-11, HP 2000, CDC 3600) and then converted wholesale to Microsoft BASIC for the microcomputer edition.

Its importance to KN-86 is that the constraints match. These are single-screen, keyboard-only, monochrome-teletype games with no graphics whatsoever, built to run in very little memory. Every mechanic in the book had to earn its place in text alone. That is the same design problem a Lisp cart on a 128×75 amber grid solves, four decades on.

Seventeen games were read for this capture, selected for mechanical interest rather than fame: Amazing, Battle, Bombardment, Combat, Depth Charge, Gomoko, Gunner, Hammurabi, Life, Life for Two, Lunar/LEM/Rocket, Nim, Orbit, Poetry, Stock Market, Super Star Trek, Tower.

Read from the printed listings and sample runs. Line numbers cite the listings as printed.

Hidden-target search

  • Depth Charge (p.55): hunt a submarine in an N-cube by entering an (X, Y, depth) trio. The shot budget is W = INT(LOG(G)/LOG(2)) + 1, i.e. floor(log2 N) + 1 (line 30): exactly enough shots to win by 3D binary search and no more. Feedback is a compound compass bearing plus a depth sign (lines ~500-590), a full gradient, which is what makes the tight budget fair rather than punishing.
  • Battle (p.15): Battleship on 6×6 against a hidden fleet. Placement (lines ~60-330) is a constraint-satisfying random packer: pick a random origin and direction, walk the ship’s length checking every cell is empty and neighbors do not collide, retry on conflict. Scored on the splash/hit ratio. The distinctive twist is that the game prints the fleet layout up front as a coded matrix, and the real objective is reverse-engineering the encoding as you play.
  • Bombardment (p.22): two 5×5 boards, four hidden platoons each, both sides fire every round. The computer’s targeting (line ~570) is uniform random with no memory and can waste shots on cells it already tried.
  • Orbit (p.124): a cloaked ship orbits at unknown angle and radius, its angle advancing a constant amount per hour. Seven shots. The entire engine is one line (~430): the law of cosines, C = sqrt(R² + D1² − 2·R·D1·cos(A − A1)), turning two polar inputs into the single scalar you triangulate from.
  • Gunner (p.77): field artillery. Impact range is the textbook range equation I = R * SIN(2*B * π/180) (line ~450), so maximum range falls at 45° and sensitivity flattens there, giving a natural difficulty gradient. Five shots, then a fresh target at a new range.

Perfect-information strategy

  • Nim (p.118): generalized multi-pile Nim with a normal/misère win option. The opponent is provably optimal: binary decomposition of each pile (lines 940-1000), a bit-column parity test that is exactly the nim-sum XOR (1020-1070), reduction to a balanced position (1120-1180), and a correct misère endgame branch (700-830, 850-1010) that flips parity once every pile is size 1.
  • Gomoko (p.74): five-in-a-row on an N×N board. The opposite of Nim: the “intelligent” move (lines 500-590) scans the eight neighbours of the human’s most recent stone and plays the first empty one, falling back to a random empty cell (600-650). No line-scan, no threat detection, and no win detection at all: the book says so outright.
  • Tower (p.173): Towers of Hanoi, refereed rather than solved. State is T(position, needle); disks carry odd size-codes (3,5,7…15) so “larger than” is a single numeric compare (lines 835-870). Legality is a top-of-stack check plus the no-larger-on-smaller rule. A 128-move abort sits just above the 2^n−1 = 127 optimum.

Economies

  • Hammurabi (p.78): ten years of Sumeria. Grain is simultaneously food, seed, and currency. Land price rolls 17-26 bushels/acre each year, harvest yield 1-5 bushels/acre, 20 bushels feeds one citizen, one person farms 10 acres, one bushel seeds two acres. Rats destroy stored grain on a coin flip (line ~522); plague halves the population about 15% of years (line ~541); births scale with prosperity (line ~533). Starving more than 45% of the population in one year is an instant loss (line 552).
  • Stock Market (p.154): $10,000 across five stocks, 1% brokerage on every transaction. The price engine (lines 830-997) is genuinely good: a market-wide trend slope applied to every stock, a per-stock daily jitter of about ±3, trend regime switching where the trend runs a random 1-5 days then flips sign and re-rolls its slope (985-997), correlated block shocks of ±10 points hitting one or two individual names on timers (833-866, 938-949), and a zero-floor rebound. The index is the mean of the five prices, so index and individual moves stay consistent.
  • Combat (p.50): allocate 72,000 troops across Army/Navy/Air Force, then commit against thresholds of the computer’s branch strengths (lines 100-390). A crude Lanchester model: commit too little and the attack is stopped with heavy loss, exceed a threshold and you wipe that branch but overextend elsewhere. No spatial component at all.

Physics and space

  • Super Star Trek (p.157): the flagship. The galaxy is an 8×8 array of quadrants, each packed into one 3-digit integer as klingons*100 + starbases*10 + stars (lines ~810-840). That single packed integer is the entire persistent galaxy, and fog-of-war falls out for free: unvisited quadrants print as ***. One energy pool (~3000) is spent three ways (warp movement, phasers, and shields), with photon torpedoes as a separate discrete resource. Eight commands, eight damageable devices, and docking at a starbase as the sole refuel/repair faucet.
  • Lunar / LEM / Rocket (p.106): three lunar-lander variants. ROCKET is simple Euler integration (V1 = V - B + G, line ~540). LUNAR is Jim Storer’s original with real mass depletion, expanding ln(1−Q) as a Taylor series because 1970s BASIC could not trust LOG on tiny arguments; because the craft lightens as it burns, braking late is doubly rewarded, which is the actual Apollo trap. LEM adds a second axis via an attitude angle.

Generative

  • Amazing (p.3): maze generator. Two per-cell arrays: V(x,y) holds a visit-order stamp, W(x,y) a wall/exit code (1 = passage right, 2 = down, 3 = both). A growing-tree carve picks a random unvisited orthogonal neighbor, writes the exit code, stamps, and moves; with no unvisited neighbor it rescans for the lowest-stamped cell that still has one. Because every cell is stamped once and each step opens exactly one wall into a previously-unvisited cell, the passages form a spanning tree, which is why the maze is always solvable by exactly one path and needs no solvability check.
  • Life (p.100): Conway B3/S23 on A(24,70). A simultaneous in-place update with no second buffer: cells that will die are tagged 2 and cells that will be born 3 during the scan (lines 590, 610), then a cleanup pass resolves markers (253-256). The neighbor count includes the center cell, so the thresholds shift by one. A tracked bounding box keeps scan and print tight around the living population.
  • Life for Two (p.102): competitive Life on 5×5. Ownership is resolved by weighted neighbor sum: player-1 cells are stamped 100*… and player-2 cells 1000 (lines 340, 351), so one accumulated integer carries both the live-neighbor count for the survive/birth decision and the per-player tally for deciding who owns a newborn cell. A new cell belongs to whichever player supplied the majority of its three live neighbors.
  • Poetry (p.128): 20 phrases in 4 groups of 5. A group counter and a computed ON J GOTO cycle output through groups 1→2→3→4 in order, imposing rough grammatical shape, while I = INT(INT(10*RND(1))/2)+1 (line 215) picks randomly within each group. A context flag U carries light state between phrases so incompatible ones do not collide, and punctuation is probabilistic: comma ~19% gated on U<>0 (line 210), indentation ~22%, new paragraph ~18% but forced at least every 20 phrases.
  • A budget derived from the search space. Depth Charge grants floor(log2 N) + 1 shots, so optimal play is bisection and the fantasy is disciplined hunting rather than luck. Deriving the resource from the problem size is the single best design idea in the book.
  • Feedback fidelity is the real difficulty dial. The same hidden-target loop appears at binary (Battle), gradient (Depth Charge), continuous-analog (Gunner), and range-scalar (Orbit) fidelities. Pick the fidelity and you have picked the genre.
  • One packed integer as the whole persistent world. Super Star Trek’s klingons*100 + bases*10 + stars holds an entire galaxy, and fog-of-war is simply “codes not yet visited.” Compact world state with free unknowns.
  • One resource wearing several hats. Hammurabi’s grain is food, seed, and currency at once; Star Trek’s energy is movement, shields, and guns. Three inputs generate real tradeoffs with no extra systems.
  • Trend plus regime-switch plus idiosyncratic shock. Stock Market’s price engine produces multi-day legs you can ride and per-name news that decouples from the index, which is what makes a market read as skill rather than noise.
  • Generation by local rule. Amazing’s spanning-tree carve guarantees solvability structurally; Life’s marker-tagging does a simultaneous update in one array; Life for Two’s decimal-place weighting carries two facts in one integer. All three are tiny and all three still hold up.
  • Ordered slots plus random fill plus a context flag. Poetry’s recipe is how you get generated text that scans as intentional from almost no code.
  • A friction cost and a survival floor. Stock Market’s 1% brokerage and Hammurabi’s 45%-starvation impeachment are each a single number that shapes the entire feel.
  • Optimality baked into scoring. Tower’s 2^n−1 gives a par to score against; Depth Charge’s log2 budget does the same implicitly.

Concept-level here; the full per-cart mapping across all 17 cartridges is in ../synthesis-basic-games.md.

  • The hidden-target search family feeds the deck’s hunt and probe carts, with Depth Charge as the honest core and its log2 budget as the mechanic to steal outright.
  • Super Star Trek’s packed-integer galaxy is a compact precedent for the World Engine’s generated-world-plus-tick-loop model, with fog-of-war as an emergent property rather than a subsystem.
  • Poetry’s slot grammar is the generative-text recipe behind CIPHER voice work and attract-mode chatter; see cipher-voice.md.
  • Hammurabi and Stock Market are the two ancestors of the campaign economy’s faucet/sink model, and Stock Market’s trend/regime/shock generator is a ready volatility model to tune against.
  • Amazing and Life are generation and attract material: a guaranteed-connected maze carve for the maps model, and a zero-asset cellular animation for the attract pipeline under the two sanctioned animation styles.
  • Nim ships a finished optimal AI; the design work is tuning it down into tiers, which is the opposite of the usual problem.

Josh’s calls, made in the kn86-inspo workbench. Full map: cart-inspiration-map.md.

GameDestination
Amazing (1978)NeonGrid
Battle (1978)Nodespace, Shellfire
Bombardment (1978)Shellfire
Combat (1978)Nodespace
Depth Charge (1978)Depthcharge
Gomoko (1978)Takezo
Gunner (1978)Shellfire
Hammurabi (1978)IF Creation Kit / propaganda
Life (1978)Nodespace
Life for Two (1978)Nodespace
Lunar / LEM / Rocket (1978)NIGHTOWL, Shellfire
Nim (1978)Takezo
Orbit (1978)Shellfire
Poetry (1978)Null
Stock Market (1978)TRADECON
Super Star Trek (1978)NIGHTOWL
Tower / Hanoi (1978)Takezo
  • Confidence: HIGH on all mechanics and algorithms. Every game above was read directly from the printed listing and its sample run in the 1978 Microcomputer Edition, not from secondary descriptions. Line-number citations refer to that printing.
  • Book identity confirmed from the title and copyright pages: Workman Publishing, copyright 1978 Creative Computing, ISBN 0-89480-052-3, first printing October 1978, edited by David H. Ahl with program conversion by Steve North.
  • Battle’s ship lengths carry an internal inconsistency. The prose describes destroyers as 2 cells, cruisers 3, and carriers 4, while the placement code seeds lengths 1, 2, and 3 per ship class. Recorded as printed; the code is authoritative for behavior.
  • Gomoko’s weakness is stated by the book itself, which notes the program “does not know when you are about to win or even who has won.” That is not an inference from the listing alone.
  • Lunar’s Taylor-series expansion is given in the book’s own notes on p.106 as −Q*(1+Q*(1/2+Q*(1/3+Q*(1/4+Q/5)))); the surrounding integration was read from the listing.
  • Not verified: exact per-line behavior of Super Star Trek’s course-interpolation tables, which were skimmed rather than traced (the game is the longest listing in the book). The galaxy-generation and combat-accounting claims above were read directly.
  • Star Trek IP. The systems are mineable; the skin is not. Any KN-86 use rethemes off the property.