Rules
The numbers that define the game.
Collected in one place so the rules can be read without hunting through Game, and so
the tests can refer to them rather than repeating magic numbers.
Definitions
The formation's speed on level 1 with every invader still alive.
A freshly dropped bomb. One place knows that a new bomb starts at age zero.
One in this many steps, some invader drops a bomb.
The base rate at which a column drops a bomb, as a one-in-N chance per tick.
Raised by half from 90 because the game was ending the wrong way. Every one of ten benchmarked games finished with the formation landing, and every one of them still had three to five spare cannons: bombs almost never killed anybody, so lives were decoration and the only real clock was the descent.
Bombs get more frequent with each level. This is a one-in-N chance, so smaller is more dangerous; it is floored so a high level cannot turn into a solid wall of bombs.
The per-level step and the floor are scaled with the base, so raising the rate keeps the shape of the curve instead of steepening it.
The crater an invader's bomb leaves.
Much bigger, and deliberately not symmetric with the cannon's. The enemy erodes your shelter faster than you can carve it, so camping is a tactic with a clock on it rather than a place to live.
The crater each kind of bomb leaves, which is where "most powerful" actually lives.
Any bomb that reaches the cannon kills it, so the three cannot differ in lethality without inventing a health bar the original never had. They differ in what they do to your cover, which is the resource the game is really about: a wiggler takes half again what a dagger does, so which kind is falling changes how long a shelter lasts.
Which kind of bomb an invader drops.
Weighted by the shape of the original's threat rather than uniformly: the plain slow bomb is the common case and the two that change the player's plan are rarer, so meeting a wiggler is an event rather than a third of the traffic.
The speed a bomb of each kind falls at.
The slow one is the old single speed, so the game a player already knows is the middle of the new range rather than the bottom of it. The dagger is fast enough to punish standing still and the wiggler is slower than either, which is what makes its sideways sweep readable instead of a blur.
One in this many bombs survives being shot.
The original's rule, and a strange-sounding one until you play it: "the player's shot is always destroyed but the invader's missile occasionally survives". The asymmetry is the point. Shooting a bomb down is never free -- it costs the shot outright, and under the one-shot rule that is the whole flight -- and it is not even reliable, so clearing a path is a gamble rather than a technique.
One in four keeps it a real risk without making the attempt pointless.
How far a wiggler sways from its column, and how long each half-sweep lasts.
The sway is a triangle wave rather than a sine: it needs no trigonometry, no phase stored beyond the bomb's own age, and -- because the horizontal step is constant -- it cannot tunnel through a bunker column the way an accelerating sweep could.
Kept under half a bunker's width so a wiggler that starts over cover stays over it.
Number of ticks for a full half-sweep oscillation of a wiggly bomb.
Score needed for an extra life.
The original awarded one bonus ship at a threshold set by a dip switch. This game never ends, so a single award would stop mattering by the third level; instead the bonus repeats at every multiple, capped so lives cannot be farmed indefinitely.
How far the damage from one hit spreads, in screen pixels.
A single block per hit looks like a pinprick; a small crater reads as damage.
The crater the cannon's own shot leaves in a bunker.
Narrow on purpose -- narrower than a bomb is wide. That is what makes the arcade's oldest trick work: drill a slit through your shelter, then stand in it and shoot out while their bombs still break on the blocks either side. A wider crater cannot do it, because the hole you make is then a hole they can drop through.
How long everything freezes when the player is hit.
A beat shorter than the wreckage lasts, so the cannon is back before the debris has quite faded and the restart does not feel abrupt.
Additional vertical drop distance applied to initial formation per level wave.
The y of the formation's lowest row at spawn -- the furthest a hit ever has to fly.
Where the formation's top row starts on a given level. Cycles every wavesPerCycle.
How long GAME OVER is held before the cabinet moves on.
Long enough to read and take in, short enough not to be waiting for it. Without a beat here a player's game ended on one frame and the next player's count started on the next, so nobody ever saw how their own game finished.
The beat between one player's game ending and the next player's starting.
The same length and the same count as the pause between waves, because it is the same idea: a moment to notice what happened and get a hand back on the controls. Handing straight over meant the incoming player's first life began while they were still reading the last one's score.
One hit box for every kind, so a squid is no harder to hit than an octopus.
def kindForRow(row: Int32): InvaderKind§ SourceWhich kind sits in each row: squid at the top, then two rows of crabs, then two of octopuses. The ones worth most are hardest to reach.
The pause between clearing a formation and the next one arriving.
Exactly one second per counted number, so the countdown on screen is a real countdown rather than a decoration that happens to reach one at about the right time. Derived rather than written out, so the two cannot drift apart.
How far the formation marches between notes of the bassline.
Spacing the notes by distance rather than by time is what makes the music accelerate with the invaders without any extra bookkeeping.
The march speed for a given number of survivors on a given level.
How many bombs the formation may have in the air at once.
Three, as in the original. Without a cap the drop chance is the only thing bounding
the bomb count, so a high level does not merely get busier -- it eventually becomes a
solid curtain no cannon can cross. bombChanceFor was floored to hold that off, which
treated the symptom; this is the rule the original actually has, and it makes the
per-level rate mean something again, because a faster drop rate now buys sooner
bombs rather than more of them.
The fastest the formation may ever march, as a fraction of the cannon's own speed.
This is the cap the level growth above was supposed to be, and was not: that one bounds only the per-level factor, and the thinning multiplier is applied after it, so the real ceiling was 0.65 x 4.0 x 3.0 = 7.8 px/tick against a cannon that does 4.0.
What breaks is not overtaking, it is closing. A cannon gaining half a pixel a tick on a receding target is as much use as one that cannot gain at all, and the shot rate tracks the closing speed all the way down. Measured over the endgame of each level, at eight invaders or fewer, before this cap existed:
| level | march | closing | shots/1000 ticks | kills/1000 |
|---|---|---|---|---|
| 1 | 1.85 | 2.15 | 48 | 31 |
| 2 | 2.27 | 1.73 | 40 | 29 |
| 3 | 2.76 | 1.24 | 31 | 24 |
| 4 | 3.37 | 0.63 | 19 | 16 |
| 5 | 4.03 | -0.03 | 17 | 12 |
So the collapse begins at level 4, not at level 5 where the formation finally overtakes the cannon -- and a cap set just under the cannon's speed would have fixed the wrong end. Three quarters leaves levels one to three untouched, their endgames being 1.85, 2.27 and 2.76, and restores level 4 to 30 shots and 25 kills per 1000 ticks. Over sixty seeds the demo goes from mean level 4.9 to 5.5 and from 43.0 ticks per kill to 36.4.
No bot-side rule fixes this, and three were tried. Waiting for the formation rather than chasing it improves every local figure -- walking falls from 3.66 px/tick to 0.86, shots rise, deaths fall -- and still loses levels, because the descent does not wait either. Chasing also walks the cannon towards the wall the formation is about to turn at, which shortens the wait for the return sweep, so it was never as pointless as it looked.
The cost is that from level 4 onwards every endgame saturates here, so the compounding growth stops separating the late levels once a formation has thinned out. What still rises with the level is the speed of a full formation -- 1.18 at level 4 against 2.60 at level 8 -- and the bomb rate. That is the trade: a late game that is hard because it is quick and thick with bombs, rather than one that is impossible because the geometry forbids a hit.
Interval of shots after the first bonus shot that awards 300 points.
What the mystery ship is worth.
The original's rule, restored: 300 points if hit with the 23rd shot of the board and on every fifteenth shot after that, and one of a fixed table otherwise.
This was a random draw here for a while, on the reasoning that the original's rule "players eventually reverse-engineered into a way to score 300 every time" and a table keeps the saucer a genuine bonus rather than a memorised trick. That reasoning had it backwards. The exploit is not a defect in the rule; it is the rule's whole texture -- counting your own shots while a formation descends is a real skill, and it is the only thing in the game that rewards planning several shots ahead. A die roll cannot be planned against, so it replaced a skill with a shrug.
Deterministic also means the saucer no longer draws from the generator, so what a player scores depends on how they played rather than on where the stream happened to be -- which is a better property for a replayable game than the randomness it cost.
Ticks between appearances, plus up to mysterySpread more.
Short enough that a saucer turns up two or three times in a level rather than once at the very end, and jittered so it does not arrive on the same beat every time.
Raised from 700 to match the guide's "roughly 25 seconds" between saucers. A rarer saucer is a higher-stakes one, and it gives the shot counter room to matter: at the old rate a player barely had time to reach the 23rd shot between appearances.
The saucer stops coming once the formation is this thin.
The original does the same. Without it the bonus turns up exactly when the last few invaders are racing across the screen and there is no attention to spare for it -- which is the worst possible moment to dangle a reward.
The saucer is stretched horizontally: three times the width, unchanged height.
Computes the score value awarded for hitting the mystery ship on shotsFired.
The saucer's hit box, derived from the sprite and the scales it is drawn at.
Computed rather than written down: a hard-coded size silently stops matching the moment a scale changes, which is exactly what happened -- the hit box stayed at the old 96px while the sprite shrank to 48, so the saucer could be hit from well outside itself.
The horizontal movement speed of the player cannon in pixels per tick.
def pointsFor(kind: InvaderKind): Int32§ SourcePoint value awarded for destroying an invader of the given kind.
How long the shield earned from the mystery ship lasts.
Long enough to be worth chasing the bonus for, short enough that you cannot bank it and stop paying attention.
The shield starts flashing this long before it fails, as a warning.
Ticks a missed shot spends in the air, and therefore the slowest the cannon can fire.
With one shot allowed on screen, the rate of fire is no longer a constant: it is the flight time of the last shot. A hit near the formation returns the cannon quickly; a miss costs the whole climb. This is the worst case, which is what the difficulty tests need to reason about.
How many of the cannon's shots may be in the air at once.
One, as in the original: "only 1 laser shot on screen at any one time". This is the rule the whole game is balanced around, and it was the largest divergence here. A twelve-tick cooldown let five shots fly at once, which made a miss cost twelve ticks; under this rule a miss costs the bullet's whole flight to the top of the screen -- about sixty-eight -- so aiming is suddenly worth more than volume.
It is a constant rather than an inlined check so the tests and the demo bot can say what they depend on.
How long the game pauses between clearing a formation and the next one appearing.
The simulation's tick rate, which Sketch.start is configured to match.
Here so that durations meant in seconds can say so. shieldTicks at 600 is ten
seconds of immunity and deathPauseTicks at 54 is a beat under a second, but neither
reads that way as a bare number.