What it does
A plan is a timeline of cues. Each cue is a hazard of some kind that warns for a while, then is live for a while, over a
set of lanes, and costs something against a budget. The director plays the plan: you tick it, ask which hazards are
warning or live and how long until each changes, ask which lanes are safe, or ask whether a given lane is live right
now. Events say when a phase starts, when a hazard warns, goes live and ends, and when the encounter is complete, each
said once.
Fairness is the point. validateEncounter checks a plan at every moment a hazard goes live or ends: at least one lane
must be free and the live cost must stay within the budget. It also checks that every hazard warns long enough for a
body in the furthest lane to cross to safety, given how many seconds a lane takes to cross. The generator only lays
hazards that keep the plan fair, and throws if the options cannot make one, so a generated encounter is beatable by
construction.
Generation runs from a seed and a few options. Phases set pressure over the encounter, from a gentle probe to a hard
finale, and pressure decides how many lanes a hazard takes, how soon the next follows and whether hazards overlap. An
intensity raises every phase towards full pressure, so one setting turns an encounter from easy to hard. What a lane
is in your world, a column, a ring or a road, and what a hit does, are up to your game.
Features
- Fair by check — a safe lane at every moment, warning long enough to reach it from the furthest lane, and the budget kept, for generated and hand-written plans alike.
- Seeded generation — lanes, length, budget, least warning, lane crossing time and calm between hazards as options, with ranges picked by seed.
- Hazard kinds as data — cost, live duration, weight and lane shape: side by side, scattered or every other lane.
- Phases and intensity — named stretches with their own pressure, and one dial to raise them all.
- A director to play it — what is warning, what is live, safe lanes, time left on each hazard and the current phase.
- Events said once —
phase,warning,active,endedandcomplete. - Snapshot and restore — save and return to a time in the encounter.
Good for
- Boss fights whose beams, slams and sweeps are telegraphed across an arena floor.
- Lane-based gauntlets, such as a runner's laser gates or a road of charges.
- Bullet-hell lanes, where the danger comes in strips rather than single shots.
- Rhythm and dodge games with hazard rows on a timeline.
- Difficulty curves by setting, raising intensity per level while every encounter stays fair.
Make it yours
The generator takes the seed, the number of lanes or a range of them, the duration, the budget, the least warning, the
time to cross a lane, the calm between hazards, the hazard kinds, the phases and the intensity. The built-in kinds are a
beam that takes side-by-side lanes, a pulse that scatters and a costlier charge on alternate lanes; the built-in
phases are probe, pressure and finale. Replace any of them with your own, or skip generation and write the cues by hand,
then run them through the validator.
Two different encounters from one pack: a forty-second boss floor of six lanes, gentle at first and closing to a finale of overlapping beams; and a short, harsh gauntlet of a dozen lanes with one kind of wide sweep, a small budget, a long warning for a slow hero, and intensity at full.
A quick look
A generated encounter played each frame, hurting the hero in a live lane and drawing warnings:
const director = createEncounter(generateEncounter({ seed: 7, lanes: 6, intensity: 0.5 }));
director.tick(dt);
if (director.live(laneOf(hero.x))) hurt(hero);
for (const h of director.hazards()) drawLanes(h.lanes, h.active ? 'burning' : 'warning', h.left);
Works with
wave-plan— for waves of enemies arriving over time.projectile-patterns— for bullet patterns from emitters.runner-core— for an endless run's obstacles.
Good to know
- Lanes are a line of equal strips, from 2 to 100 of them; what a lane is in the world is your game's.
- A plan is fair for a body that crosses a lane in the plan's lane time; give a slower one more warning.
- The director keeps time, not state: restoring returns to a time, and events from there are said again.
- It draws and moves nothing, and decides nothing about damage.






