21. Reference tests and verification
How do we know this document is right, and how do you know your rebuild is? This chapter answers both. It describes how the document was checked against the original program, including a test in which people who could read nothing but these pages rebuilt parts of the game and were compared, case by case, with the original code. Then it gives reference cases you can use without any of our tools: concrete inputs and the exact outputs of the original, produced by running its code. Marks: O observed, D derived from the code, H hypothesis (chapter 0).
How this document was checked
The program behind it
Everything here is read from a reconstructed source of NetWars 2.06 that rebuilds the original
NETWARS.EXE byte for byte: the same SHA-256, built with the original Borland
C++ 2.0 toolchain, every C function byte-identical when compiled, the hand-written assembly
modules part of the identical image O
(docs/build.md, docs/verification.md).
So a statement about "the code" is a statement about the shipped program, not about a guess at it.
What the code does at run time was also watched: recorded runs of the original in an emulator,
with keys and forced states injected (docs/runtime-baseline.md).
Critics
Each chapter (0 to 21) was read, after it was written, by a critic who had not written it (a newcomer or fact-checking reader) and who checked its claims against the sources and the recorded runs; the corrections were made before the chapter was kept. Chapters 18 and 19 had two such passes, this chapter one. The writer assigns the marks O, D, H; the critic checked each against its source, and a claim without a source or a run is marked as a hypothesis.
The sufficiency check
Correct is not the same as sufficient: a true document can still leave out the one rule a rebuild needs. So the document was tested the way it is meant to be used O:
- Implementers restricted to the document. The implementers were AI agents, fresh
ones each round with no prior context. They were instructed to read only these HTML pages, the
readable data in
assets/and a short description of the functions to write (tools/doccheck/API.md: inputs, outputs and units, no rules). They wrote those functions in Python and noted every place where the text was unclear or silent and what they assumed. The restriction was an instruction, not a sandbox: in round 3 the parallel implementers shared one scratch directory, and a copy of an off-limits source file appeared in it; implementer C reports not opening it (round3_analysis.md, N47). Later rounds use a separate scratch directory per implementer. - The original as the oracle. The same functions were answered by running the
original machine code in a CPU emulator (Unicorn): the inputs are written into the
game's own records and variables, the original routine runs unchanged, and the results are
read back. Routines outside the one tested are replaced by recorders: drawing, sound, the
timer,
rand()(which hands out given values), the network, the death screen and, for the single-function tests, neighbouring routines; oracle_notes.md lists each. - Seeded cases. A comparer generates the same random cases for both from a fixed seed: normal inputs and edge ranges (exact limits, powers of two, objects straight ahead, near misses), plus whole frames sampled from trajectories of the original itself. A case passes when every discrete output (states, flags, counters, messages, sounds) is equal and every continuous one is within a small tolerance (positions 1 unit, axes 0.01, pixels 1.5).
- Every mismatch is classified. Either the document was silent, vague or wrong (then the chapter is fixed), or the implementer missed something the text states, or the test's own conventions were unclear (then the function description is fixed; the oracle never changes what the original computes).
The 19 functions and what each covers:
| # | Function | What it covers | Original code run | Cases |
|---|---|---|---|---|
| 1 | distance exponent | the nearness measure behind every contact and range test (chapter 3) | lvec3_normalize_down/up | 700 |
| 2 | ship step | one frame of your ship: keyboard ramps, tumble, throttle, velocity controller, extra thrust (chapter 4) | player_update | 500 |
| 3 | laser hit | your shot's box test against a body (chapter 6) | shot_hits_object | 700 |
| 4 | alien laser hit | an alien shot's box test against you | alien_shots_update | 700 |
| 5 | render one body | display exponent, touch, view test, far "+", screen position, the faces queued and their order (chapter 9) | render_object and the draw list | 400 |
| 6 | Fighter step | the Fighter's behaviour and movement (chapter 7) | ai_fighter, object_move | 500 |
| 7 | hit reports | multiplayer: applying the hit words of the peers (chapter 8) | net_sync_frame | 500 |
| 8 | radar blip | one object's radar mark at every zoom level (chapter 15) | render_object, draw_radar | 600 |
| 9 | HUD | every line, text and stroke letter of the instruments (chapter 15) | draw_hud, radar frame | 300 |
| 10 | alien step | all four kinds and the mutant in every state: behaviour, movement, ramming, explosions, the lock test (chapters 7, 17) | aliens_update | 600 |
| 11 | missile step | your missile and both enemy missiles: homing, hits, giving up, score wrap | player_missiles_update, enemy_missiles_update | 500 |
| 12 | missile lock | the crosshair lock and the launch | aliens_update, player_fire_missile | 300 |
| 13 | pod step | a pod in every state (chapter 5) | pods_update | 400 |
| 14 | satellite step | spin, loss, pick-ups and their limits | satellite_update, apply_pickup | 400 |
| 15 | satellite spawn | position, kind cycle, counter wrap | satellite_spawn | 200 |
| 16 | level set-up | budgets, limits, Pirate speed, pod reset and placement | main from its level label | 150 |
| 17 | alien spawn | slot, kind rotation, mutants, spawn side | alien_spawn | 300 |
| 18 | sound sequence | the PC-speaker sequencer tick by tick (chapter 10) | snd_effect_N, snd_tick | 150 |
| 19 | frame step | one whole single-player frame of the main loop, everything except drawing (chapters 2, 17) | main's frame loop | 300 |
Results, per function, as the share of cases that pass. Rounds 1 and 2 tested functions 1–7 on chapters 0–9; round 3 had three implementers, each with a part of functions 1–19, on all chapters. The last column is the same round-3 code compared again after the test's own conventions were corrected (the code itself unchanged; mismatches that came from gaps in the document stay, since the gaps were fixed in the text, not in the implementations):
| Function | Round 1 | Round 2 | Round 3 | Round 3, final conventions | Why not 100 at first; what remains |
|---|---|---|---|---|---|
| 1 distance exponent | 100 | 100 | 100 (all three) | 100 | — |
| 2 ship step | 89.6 | 99.6 | 100 | 100 | — |
| 3 laser hit | 93.4 | 100 | 100 | 100 | — |
| 4 alien laser hit | 93.9 | 100 | 100 | 100 | — |
| 5 render one body | 68.2 | 92.8 | 98.2 | 98.2 | the vertex arithmetic close up (16-bit wrap): now written out in chapter 9 |
| 6 Fighter step | 78.8 | 99.6 | 100 | 100 | — |
| 7 hit reports | 91.8 | 100 | 100 | 100 | — |
| 8 radar blip | 100 | 100 | — | ||
| 9 HUD | 100 | 100 | — | ||
| 10 alien step | 100 | 100 | — | ||
| 11 missile step | 100 | 100 | — | ||
| 12 missile lock | 100 | 100 | — | ||
| 13 pod step | 100 | 100 | — | ||
| 14 satellite step | 94.0 | 94.0 | a test convention (what a freed satellite reports), now stated | ||
| 15 satellite spawn | 86.5 | 86.5 | the 16-bit counter wrap: now in chapter 17 | ||
| 16 level set-up | 42.7 | 100 | a test convention (lost pods) | ||
| 17 alien spawn | 100 | 100 | — | ||
| 18 sound sequence | 100 | 100 | — | ||
| 19 frame step | 93.3 | 97.3 | fixed: two values the test forgot to carry from frame to frame, and a powered shot at life 0 reported as a free slot (test conventions); remaining 2.7 %: only the death-screen convention (the death screen is outside the step), now stated |
Every gap the rounds found was written into the chapters, mostly as "Exact rules" boxes: round 1 gave the precision rules of chapter 3, the keyboard and tumble details of chapter 4, the box tests of chapter 6, the Fighter's same-frame switch and the hit-report rules; round 2 the last roundings; round 3 the vertex arithmetic and culling formula of chapter 9, the satellite counter wrap, the "None" sound option, the status-line calls of chapter 15, the switch convention and the missile hit frame of chapter 17, and a satellite rule nobody had noticed: a dead ship that touches a shields satellite lives again (chapter 17, 8) O. Round 3 found no implementer slip: every difference came from the document or from the test's conventions. The round-3 fixes themselves have not been re-tested by a fresh implementer; the render_body fix was confirmed only by changing implementer C's vertex arithmetic to the new rule in a copy (400 of 400 cases then pass).
- Multiplayer beyond hit reports: remote ships and their shots, peer satellites, the lobby, the packets. Chapters 8 and 14 describe them; they were checked against recorded runs and packet captures, not by an implementer.
- Screens and menus: title, level menu, name entry, level introduction and completion, the death screen itself, the high-score table.
- Drawing below the line level: how lines and polygons become pixels, the fonts' pixels, explosion sparks, the starfield.
- Mouse steering: the ship step was tested with the keyboard only.
- Network effects of shots beyond the hit words, and the level-complete screen inside the frame step (the step stops where the loop ends).
- Bit-exactness. A pass means equal discrete values and continuous values within the comparer's tolerances: positions 1 world unit, velocities 0.05 units per frame, speeds 0.01 units per frame, axes 0.01 (about 164 Q14 steps), screen points 1.5 pixels. The bit-exact values are pinned only by the reference tables below and the "Exact rules" boxes of the chapters.
- The browser protocol of chapters 18 and 19: it is a design for a new program, so there is no original to compare with.
Reference cases
The tables below are inputs and the outputs of the original code, produced by the same oracle as the sufficiency check and generated, not typed (the generator keeps this page and the original in step). Use them as unit tests: if your rebuild gives a different number, read the chapter named in the heading again. Formats: positions and velocities in world units (exact decimals: the game counts in 1/65536 units), axes as Q14 integers (16384 = 1.0), speeds in world units per frame, rates in steps of 1/2048 turn per frame, pixels of the 640 × 350 screen with the origin included. Axis c is called "up" but points toward the bottom of the screen (chapter 3, chapter 15): a positive camera y is drawn below the centre. Unless a table says otherwise: single player, Polygons mode, shields 32, no bump immunity.
Distance exponents (chapter 3, chapter 17 2.2)
Vector (dx, 0, 0) in world units; start 0 = steering exponent, start 1 = display exponent of a scale-1 body (a scale-0 body has the start-0 column). Other axes 0.
| dx | start 0 | start 1 |
|---|---|---|
| 0 | 8 | 8 |
| 127 | 7 | 8 |
| 128 | 6 | 7 |
| 255 | 6 | 7 |
| 256 | 5 | 6 |
| 1000 | 4 | 5 |
| 1023 | 4 | 5 |
| 1024 | 3 | 4 |
| 8191 | 1 | 2 |
| 8192 | 0 | 1 |
| 16384 | 0 | 1 |
| 16385 | -1 | 0 |
| -16385 | 0 | 1 |
| -16386 | -1 | 0 |
| 32769 | -1 | 0 |
| 32770 | -2 | -1 |
| 65540 | -3 | -2 |
Your ship, one frame (chapter 4, chapter 17 3)
Start: at the origin, identity axes (fwd (0, 0, 16384), right (16384, 0, 0), up (0, 16384, 0)), rates 0, shields 32, keyboard; the tumble counter is already counted down for this frame. Throttle is the requested forward speed in world units per frame (0x90 = 144 = full, −0x70 = −112 full reverse); extra thrust is the pick-up stock (0x400 per thrust satellite, at most 0x1000), used up one unit per axis correction. The rates column is pitch, yaw, roll; the tumble rates column is in the game's own order [pitch, roll, yaw].
| case | pitch, yaw, roll rate | throttle | extra thrust | velocity | position | fwd (Q14) | right (Q14) | tumble rates [pitch, roll, yaw] |
|---|---|---|---|---|---|---|---|---|
| at rest, Shift (throttle up) + Right (yaw) held | 0, 2, 0 | 8 | 0 | (0.0123291015625, 0, 2) | (0.0123291015625, 0, 2) | (101, 0, 16384) | (16384, 0, -97) | [0, 0, 0] |
| at rest, Up held | -2, 0, 0 | 0 | 0 | (0, 0, 0) | (0, 0, 0) | (0, -101, 16384) | (16384, 0, 0) | [0, 0, 0] |
| full throttle 0x90, flying at 144, nothing held | 0, 0, 0 | 144 | 0 | (0, 0, 144) | (0, 0, 144) | (0, 0, 16384) | (16384, 0, 0) | [0, 0, 0] |
| the same with extra thrust 0x400 | 0, 0, 0 | 144 | 1023 | (0, 0, 160) | (0, 0, 160) | (0, 0, 16384) | (16384, 0, 0) | [0, 0, 0] |
| full throttle, Ctrl held | 0, 0, 0 | 136 | 0 | (0, 0, 142) | (0, 0, 142) | (0, 0, 16384) | (16384, 0, 0) | [0, 0, 0] |
| tumbling (rates pitch 16, roll -8, yaw 4) | 15, 3, -7 | 0 | 0 | (0, 0, 0) | (0, 0, 0) | (150, 751, 16367) | (16381, -355, -130) | [15, -7, 3] |
Your laser: hit or miss (chapter 6, chapter 17 7.3)
Shot at the origin after its move, identity axes; target centre and model scale. Box: ±512 along the flight, ±192 (scale 1) or ±96 (scale 0) across, limits included.
| target centre | scale | hit |
|---|---|---|
| (0, 0, 512) | 1 | yes |
| (0, 0, 513) | 1 | no |
| (0, 0, -512) | 1 | yes |
| (192, 0, 0) | 1 | yes |
| (193, 0, 0) | 1 | no |
| (0, -192, 300) | 1 | yes |
| (96, 0, 0) | 0 | yes |
| (97, 0, 0) | 0 | no |
| (0, 0, 400) | 0 | yes |
Alien laser and the pass-through (chapter 6, chapter 17 7.5)
You at the origin; an alien shot flying along +z (identity axes), tested where it is after its move. Box in the shot's axes: ±1024 sideways (right), ±256 up and ±256 along the flight, limits included. It moves 1,024 units per frame, so a shot tested at −512 and next at +512 has passed through you without a hit (Authentic A3).
| shot position | hit |
|---|---|
| (0, 0, -512) | no |
| (0, 0, -256) | yes |
| (0, 0, 0) | yes |
| (0, 0, 256) | yes |
| (0, 0, 257) | no |
| (0, 0, 512) | no |
| (1024, 0, 0) | yes |
| (1025, 0, 0) | no |
| (0, 256, 0) | yes |
| (0, 257, 0) | no |
Radar marks (chapter 15)
You at the origin, identity axes; the object at the given position. Screen pixels (origin included); the stalk runs from the radar-plane point to the mark; the plus is centred on the mark. Zoom −1 is the start value.
| object at | kind | zoom | stalk | plus centre | colour |
|---|---|---|---|---|---|
| (300, -500, 2000) | alien | 2 | (556, 270)–(556, 262) | (556, 262) | 10 |
| (300, -500, 2000) | alien | -1 | (552, 284)–(552, 283) | (552, 283) | 10 |
| (300, -500, 2000) | pod | -1 | (552, 284)–(552, 283) | (552, 283) | 13 |
| (-3000, 1000, -6000) | satellite | -1 | (546, 291)–(546, 292) | (546, 292) | 15 |
| (-3000, 1000, -6000) | enemy_missile | 0 | (540, 297)–(540, 300) | (540, 300) | 14 |
| (20000, 0, 0) | alien | -1 | (591, 285)–(591, 285) | (591, 285) | 10 |
| (20000, 0, 0) | alien | -2 | (571, 285)–(571, 285) | (571, 285) | 10 |
| (40000, 0, 0) | alien | -6 | (554, 285)–(554, 285) | (554, 285) | 10 |
A Fighter, one frame (chapter 7, chapter 17 4.4)
You at the origin. Fighter: speed 175 = its top speed, accel 0, turn limit 24, rates 0 before; "nose on you" = fwd (0, 0, −16384), right (−16384, 0, 0), up (0, 16384, 0). The display exponent is the one the renderer left in the previous frame.
| case | display exp. before | state after | pitch, yaw, roll rate | speed | position after | fwd after (Q14) | fires |
|---|---|---|---|---|---|---|---|
| 3000 ahead of you, nose on you, frame 4 | 3 | attack | 0, 0, 0 | 175 | (0, 0, 2825) | (0, 0, -16384) | yes |
| the same, frame 5 | 3 | attack | 0, 0, 0 | 175 | (0, 0, 2825) | (0, 0, -16384) | no |
| 1500 away, nose on you (attack falls through to retreat) | 4 | retreat | 24, 0, 0 | 175 | (0, 12.8814697265625, 1325.469970703125) | (0, 1206, -16340) | yes |
| 3000 away, you 45° to its right | 3 | attack | 1, -24, 0 | 175 | (-2987.1185302734375, 0.54473876953125, 2825.469970703125) | (1206, 51, -16340) | no |
| retreating, 9000 away, facing away (turns back) | 1 | attack | 0, 0, 0 | 175 | (0, 0, 9175) | (0, 0, 16384) | no |
A Pirate escaping with a pod (chapter 7, chapter 17 4.3)
Pirate in state "escape" at (−1500, 0, 0) flying along −x at 125 units per frame with pod 0 in tow; aliens left 8, pods left 6. The escape test uses the display exponent of the previous frame (< 0 = escaped). "–": the slot was freed (its record keeps leftovers that nothing reads).
| case | display exp. before | alien exists | state | display exp. after | position after | aliens left | pods left | pod 0 exists | message | sounds |
|---|---|---|---|---|---|---|---|---|---|---|
| you 40000 units away: escapes | -1 | no | – | – | – | 7 | 5 | no | POD DESTROYED | [] |
| you 20000 units away: keeps fleeing | 0 | yes | escape | 0 | (-1625, 0, 0) | 8 | 6 | yes | – | [] |
Your missile: a hit and the score wrap (chapter 6, chapter 17 5.4, 9.2)
Your missile homing at the origin along +z, speed 400, accel 25, turn 128; the target is a Commander (8 hit points, 400 points). A hit is the steering exponent missile → target ≥ 6 (every axis within [−256, 256)). The score wraps at 1,000,000. In the hit frame the missile slot is processed again at once: age 2, no move. "Exp. / age" is the display exponent while the missile flies and the explosion age once it explodes (the same field).
| case | missile state | missile exp. / age | missile position | speed | target exploding | target hit points | target age | score | sounds |
|---|---|---|---|---|---|---|---|---|---|
| Commander 200 ahead, score 999950 | exploding | 2 | (0, 0, 0) | 400 | yes | 0 | 1 | 350 | [0] |
| Commander 600 ahead | homing | 5 | (0, 0, 400) | 400 | no | 8 | 0 | 999950 | [] |
A Pirate's missile (speed 100, turn 8) flying along +z toward you at the origin. Its hit test is its display exponent to you ≥ 6 (scale 0: every axis within [−256, 256)), after its move. "Exp. / age" as above: display exponent while homing, explosion age while exploding.
| case | state | exp. / age | position | shields | death countdown | flash | sounds |
|---|---|---|---|---|---|---|---|
| 300 behind you, closing, shields 1 | exploding | 0 | (0, 0, -200) | 0 | 64 | hit | [1] |
| 300 behind you, shields 0 (dead) | homing | 6 | (0, 0, -200) | 0 | 0 | – | [] |
| 700 behind you, shields 5 | homing | 4 | (0, 0, -600) | 5 | 0 | – | [] |
Level budgets (chapter 7, chapter 17 4.2)
Single player, Polygons mode, at the start of the level; "pods before" = pods left from the previous level (all six or none). Counts are Pirates, Fighters, Guardians, Commanders still to come.
| level | pods before | aliens at once | counts | aliens left | pods left | Pirate top speed | explosion sparks |
|---|---|---|---|---|---|---|---|
| 1 | 6 | 4 | [8, 0, 0, 0] | 8 | 6 | 125 | 38 |
| 5 | 6 | 4 | [8, 8, 6, 2] | 24 | 6 | 125 | 38 |
| 10 | 6 | 4 | [8, 8, 8, 8] | 32 | 6 | 175 | 38 |
| 13 | 6 | 4 | [8, 8, 8, 8] | 32 | 6 | 250 | 38 |
| 16 | 6 | 7 | [8, 8, 8, 8] | 32 | 6 | 250 | 38 |
| 17 | 6 | 8 | [8, 8, 8, 8] | 32 | 6 | 250 | 38 |
| 7 | 0 | 4 | [0, 0, 0, 30] | 30 | 0 | 125 | 38 |
Satellite appearance (chapter 7, chapter 17 8.1)
The every-128th-frame spawn with the given counter and rand() values (x, y, z in that order). Kinds: 1 shields, 2 missiles, 3 extra thrust, 4 fire power. The counter is a signed 16-bit number.
| counter before | rand() | one already out | counter after | kind | position |
|---|---|---|---|---|---|
| 5 | [0, 16384, 32767] | no | 6 | 4 | (-10000, 0, 9999) |
| 0 | [1, 2, 3] | no | 1 | 3 | (-10000, -9999, -9999) |
| 2 | [32767, 32767, 32767] | no | 3 | 1 | (9999, 9999, 9999) |
| 32767 | [100, 200, 300] | no | -32768 | 2 | (-9939, -9878, -9817) |
| -1 | [16383, 16384, 16385] | no | 0 | 2 | (-1, 0, 0) |
| 2 | [5000, 5000, 5000] | yes | 2 | – | – |
Overlapping sound effects (chapter 10)
One row per timer tick; an effect started in a row starts just before that row's tick. Effect 2 (pick-up) is cut by 5 (laser), which is cut by 1 (hit); the start of 0 at shields 0 is ignored; the option "None" freezes the sequencer for two ticks. Divisor = the PIT channel-2 divisor; frequency = 1,193,182 ÷ divisor Hz.
| tick | start | shields | option | divisor sounding |
|---|---|---|---|---|
| 0 | 2 | 32 | PC Speaker | 1664 |
| 1 | – | 32 | PC Speaker | 1664 |
| 2 | 5 | 32 | PC Speaker | 5120 |
| 3 | – | 32 | PC Speaker | 1536 |
| 4 | – | 32 | PC Speaker | 6144 |
| 5 | – | 32 | PC Speaker | 10240 |
| 6 | – | 32 | PC Speaker | 14336 |
| 7 | – | 32 | PC Speaker | 18432 |
| 8 | – | 32 | PC Speaker | 22528 |
| 9 | 1 | 32 | PC Speaker | 1024 |
| 10 | – | 32 | PC Speaker | 2048 |
| 11 | – | 32 | PC Speaker | 4096 |
| 12 | – | 32 | PC Speaker | 8192 |
| 13 | 0 | 0 | PC Speaker | 16384 |
| 14 | – | 0 | PC Speaker | 32768 |
| 15 | – | 32 | PC Speaker | 36864 |
| 16 | – | 32 | PC Speaker | 40960 |
| 17 | – | 32 | None | 40960 |
| 18 | – | 32 | None | 40960 |
| 19 | – | 32 | PC Speaker | off |
| 20 | – | 32 | PC Speaker | off |
| 21 | – | 32 | PC Speaker | off |
One whole frame (chapter 2, chapter 17 1.1)
Level 1 just set up (six idle pods 1000 units out on the axes, 8 Pirates to come, 4 at once), you at the origin at rest with identity axes, 16 missiles, frame counter 63, satellite counter 0; Space and Shift held; rand() returns 1000, 2000, … Everything the frame changed. The shot hit pod 3 in its first test: "explosion −8" is its state word 0xFFF8 read as a signed number (chapter 17, 7.1), counting up to 0. For the pod, "display exponent / age" is the explosion age once it explodes (the same field).
| what | after the frame |
|---|---|
| frame counter | 63 → 64 |
| throttle, velocity, position | 8, (0, 0, 2), (0, 0, 2) |
| fire cooldown | 2 |
| shot (slot 0) | position (0, 64, 1024), velocity (0, 0, 1024), explosion -8 |
| pod 3 (home (0, 0, 1000)) | exploding, display exponent / age 1 |
| alien spawned | slot 0, pirate, state attack, position (16374.7989501953125, 0.38909912109375, 126.664306640625), speed 125, hit points 2, display exponent 1 |
| counts still to come, spawn direction, type rotation | [7, 0, 0, 0], 1, 1 |
| aliens left, pods left | 8, 5 |
| sounds, message, flash, rand() values used | [5, 0], –, –, 0 |
Shots against a pod over several frames (Authentic A1, A2)
Same world without the frame-63 spawn (counter starts at 1), Space held from the first frame, one pod moved straight ahead of you; the other pods stay at their homes. Columns: in which frame (1 = the first) the first shot hits the pod, if at all within the shot's 24 frames.
| case | hit in frame |
|---|---|
| pod 1000 ahead, at rest | 1 |
| pod 400 ahead, at rest (too close: A2) | never |
| pod 1750 ahead, full throttle (skipped over: A1) | never |
| pod 2400 ahead, full throttle | 2 |
Testing Authentic mode
Chapter 20 defines Authentic as "every rule, bugs included, at the original step rates". The cases above already pin several of its bugs: the laser that skips a target at full throttle (A1) and cannot hit one 400 units ahead (A2), the alien shot that passes through you (A3), the score wrap, the satellite counter wrap. Beyond single functions, test whole runs:
- Same inputs, same random numbers, same states. Seed Borland's
rand()(chapter 17, 1.4) with a fixed value, feed a recorded key script frame by frame (which keys are latched at the top of each frame), and run N frames. Two runs must give identical states; a hash of the state per frame makes the first difference easy to find. - Against the original. The same script and seed in the original program (or its code in an emulator, as here) must give the same states frame by frame. The frame of the first difference and the variable that differs point to the rule to read again.
- Step clock. 60 seconds of single player are about 1,092 steps (18.2065 per second: 1,092 or 1,093 depending on the tick phase); a multiplayer session steps at its agreed rate (chapter 20).
- Modern mode passes the same tests except the rows that chapter 20 marks "fix" or whose option is changed; each fix gets its own test of the new behaviour.
Log in the game's own units, so values can be compared exactly: the frame counter; the keys
latched; how many rand() values were drawn; your position and velocity (raw 64-bit),
axes (Q14), turn rates, throttle, extra thrust, shields, death countdown, bump immunity, tumble,
score, missiles, fire power; for every alien, missile, pod, satellite and shot slot: type, state,
position, axes, speed, rates, display exponent, hit points, target; the counters (aliens left,
pods left, budgets, spawn rotations, satellite counter); and the frame's side effects: message and
its timer, flash colour, sounds started. A difference in a side effect with equal states usually
means an order problem inside the frame (chapter 17, 1.1).
How to rerun the check
The tools live in the private reconstruction repository, because they need the original program (its unpacked load image) to run the oracle (tools/doccheck/README.md):
.venv/bin/python -I tools/doccheck/compare.py path/to/impl.py [--only fn1,fn2] [--out report.md]
.venv/bin/python -I tools/doccheck/compare.py tools/doccheck/oracle.py # self-check: 100 %
.venv/bin/python -I tools/doccheck/ref_cases.py --write # regenerate the tables above
.venv/bin/python -I tests/test_ref_cases.py # page equals generator
The function descriptions an implementer gets are in tools/doccheck/API.md; the oracle's conversions and replaced routines in tools/doccheck/oracle_notes.md; every round's implementations, notes and reports, and the analysis of round 3, in evidence/doccheck/. A whole comparison takes about a minute.
What a rebuild should test first
- The integer helpers of chapter 17, 2.1–2.2:
dotwith its 32-bit wrap,crosswith the lost borrow,rotate, and the distance exponent (first table above, all rows). Everything else is built on them. - Your ship from rest for a few frames with each key (second table), then with tumble.
- The box tests: laser, alien laser, contact (exponent ≥ 7), missile contact (≥ 6), at their exact limits.
- One Fighter and one Pirate through all their states; a missile hit in the same frame as the explosion start; the score wrap.
- Level budgets for levels 1, 5, 10, 13, 16, 17 and the no-pods level; the spawn rotation; the satellite cycle from a fresh program start (first kind: extra thrust).
- The frame order (chapter 17, 1.1) with one whole frame (the frame table above), then hundreds of frames against a recording with a fixed seed.
- The renderer's numbers that the rules use (display exponent, camera coordinates, the view test) before the picture; then the picture.
- Sound: the sequencer table, with an effect cut by another.