flix

0.81.0

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

def baseMarchSpeed(): Float32§ Source

The formation's speed on level 1 with every invader still alive.

def bombAt(pos: Vec2, kind: BombKind): Bomb§ Source

A freshly dropped bomb. One place knows that a new bomb starts at age zero.

def bombChance(): Int32§ Source

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.

def bombChanceFor(level: Int32): Int32§ Source

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.

def bombCrater(): Float32§ Source

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.

def bombCraterFor(kind: BombKind): Float32§ Source

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.

def bombKindFrom(rng: Rng): (BombKind, Rng)§ Source

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.

def bombSize(): Vec2§ Source

Bounding size of an invader bomb.

def bombSpeedFor(kind: BombKind): Float32§ Source

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.

def bombSurvivesShot(): Int32§ Source

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.

def bombWiggleSpeed(): Float32§ Source

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.

def bombWiggleTicks(): Int32§ Source

Number of ticks for a full half-sweep oscillation of a wiggly bomb.

def bonusLifeScore(): Int32§ Source

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.

def bulletCrater(): Float32§ Source

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.

def bulletSize(): Vec2§ Source

Bounding size of a player cannon bullet.

def bulletSpeed(): Float32§ Source

Upward flight speed of a player bullet in pixels per tick.

def bunkerCell(): Float32§ Source

One block of a bunker, in screen pixels.

def bunkerColumns(): Int32§ Source

Number of block columns per bunker shelter.

def bunkerCount(): Int32§ Source

Number of bunker shelters spaced across the screen.

def bunkerLeft(index: Int32): Float32§ Source

The x of the left edge of bunker index.

def bunkerRows(): Int32§ Source

Number of block rows per bunker shelter.

def bunkerTop(): Float32§ Source

Y position of top edge of bunkers.

def cannonScale(): Float32§ Source

Scale multiplier applied to the cannon sprite.

def columnSpacing(): Float32§ Source

Horizontal spacing between invader origins in pixels.

def columns(): Int32§ Source

Number of columns of invaders in a full formation.

def countdownSteps(): Int32§ Source

How many numbers the between-levels countdown shows.

def deathPauseTicks(): Int32§ Source

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.

def descentPerWave(): Float32§ Source

Additional vertical drop distance applied to initial formation per level wave.

def fieldHeight(): Float32§ Source

Playfield boundary height in screen pixels.

def fieldWidth(): Float32§ Source

Playfield boundary width in screen pixels.

def formationBottom(): Float32§ Source

Y coordinate of the bottom invader row at level 1 spawn.

def formationBottomFor(level: Int32): Float32§ Source

The y of the formation's lowest row at spawn -- the furthest a hit ever has to fly.

def formationLeft(): Float32§ Source

X coordinate of the leftmost invader column at spawn.

def formationTop(): Float32§ Source

Default Y coordinate of the top invader row at spawn on level 1.

def formationTopFor(level: Int32): Float32§ Source

Where the formation's top row starts on a given level. Cycles every wavesPerCycle.

def gameOverTicks(): Int32§ Source

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.

def groundY(): Float32§ Source

The green line the cannon stands on.

def handoverTicks(): Int32§ Source

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.

def invaderBlastTicks(): Int32§ Source

How long an invader's starburst stays on screen.

def invaderSize(): Vec2§ Source

One hit box for every kind, so a squid is no harder to hit than an octopus.

def invasionLine(): Float32§ Source

Invaders reaching this line end the game.

def kindForRow(row: Int32): InvaderKind§ Source

Which 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.

def levelPauseTicks(): Int32§ Source

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.

def marchDrop(): Float32§ Source

How far the formation drops each time it reaches a wall.

def marchNoteDistance(): Float32§ Source

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.

def marchSpeedFor(living: Int32, level: Int32): Float32§ Source

The march speed for a given number of survivors on a given level.

def maxBombs(): Int32§ Source

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.

def maxLives(): Int32§ Source

Maximum cap on accumulated player lives.

def maxMarchSpeed(): Float32§ Source

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.

def mysteryBonusEvery(): Int32§ Source

Interval of shots after the first bonus shot that awards 300 points.

def mysteryFirstBonusShot(): Int32§ Source

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.

def mysteryInterval(): Int32§ Source

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.

def mysteryMinInvaders(): Int32§ Source

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.

def mysteryScaleX(): Float32§ Source

The saucer is stretched horizontally: three times the width, unchanged height.

def mysteryScaleY(): Float32§ Source

The saucer scale factor on the Y axis.

def mysteryScoreFor(shotsFired: Int32): Int32§ Source

Computes the score value awarded for hitting the mystery ship on shotsFired.

def mysterySize(): Vec2§ Source

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.

def mysterySpeed(): Float32§ Source

Speed at which the mystery saucer flies horizontally.

def mysterySpread(): Int32§ Source

Random jitter range added to mysteryInterval.

def mysteryY(): Float32§ Source

High enough to be clear of the formation's starting row.

def playerBlastTicks(): Int32§ Source

How long the cannon's wreckage stays on screen.

def playerSize(): Vec2§ Source

Matches the cannon sprite at spriteScale x 3: 13 x 8 pixels.

def playerSpeed(): Float32§ Source

The horizontal movement speed of the player cannon in pixels per tick.

def playerY(): Float32§ Source

The fixed vertical baseline Y position of the player cannon.

def pointsFor(kind: InvaderKind): Int32§ Source

Point value awarded for destroying an invader of the given kind.

def rowSpacing(): Float32§ Source

Vertical spacing between invader origins in pixels.

def rows(): Int32§ Source

Number of rows of invaders in a full formation.

def shieldTicks(): Int32§ Source

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.

def shieldWarningTicks(): Int32§ Source

The shield starts flashing this long before it fails, as a warning.

def shotFlightTicks(): Int32§ Source

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.

def shotsAloft(): Int32§ Source

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.

def spriteScale(): Float32§ Source

Screen pixels per sprite pixel.

def startingLives(): Int32§ Source

Number of lives a player starts with at the beginning of a game.

def ticksPerSecond(): Int32§ Source

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.

def totalInvaders(): Int32§ Source

Total count of invaders in a full initial formation.

def wavesPerCycle(): Int32§ Source

How much lower each wave starts than the one before, and how many waves before the cycle resets.