Survivor Market: enemy spawns
A survivor settlement in an old railway shed — trade at six stalls, rest among the people who live here, then ride on.
- Level id
market- Difficulty tier
- 1 — Explicit difficulty tier of the level (0 = the starting level). Metadata only: no automatic scaling of counts, damage or loot, and no enemy family is enabled by it.
LEVELS.market.tierin game/src/levels/registry.ts:106 (repository access required) - Spawn profile
- Survivor Market (calm: no enemies) —
MARKET_SPAWN_PROFILEin game/src/ai/spawnTables.ts:799 (repository access required) - Spawns tried per level
- 0 (E = 0), over 2 generation contexts
- Room modifiers
- All 0 room keys resolve to 1× for every family (neutral); the profile sets no room modifiers
Generation contexts
A generation context is one run of the enemy placement code. Each run draws one count, uniformly from its range, and tries to place that many spawns. The contexts below are parts of the one Survivor Market level and are generated with it; they are not separate levels. A context that runs more than once per level (for example once per storey) draws a new count each run.
| Context | Storeys one run covers | Runs per level | Count per run | E[count] per run | Per level | E per level |
|---|---|---|---|---|---|---|
| The settlement (platform, stalls, square, housing deck): none — a calm pit stopstation data hook | the whole settlement (platform, stalls, square, housing deck) | 0 | 0U{0..0} | 0 | 0 | 0 |
| Service annex (per annex)service | none: the market grows no service annex (LEVELS.market.trackExtensions none) | 0one per zone (seeded) | 5–6U{5..6} | 5.5 | 0zone budget, not in the total | 5.5per zone |
| Whole level | all core contexts (zones reported separately) | 0 | 0 |
Spawns the level's context runs try to place (Σ runs × count). The family roll replaces, never adds; placed totals can fall short where eligible, spaced cells run out. Not included: the zone context 'service' (a per-zone budget of 5-6 per zone, 0-0 per level), reported separately.
Service annex (per annex): A PER-ANNEX ZONE BUDGET: one run per seeded service annex (0 to TRACK_EXT.annex.max per level, a generation census quantity — see docs/enemy-spawns.md "Service annexes"), on the annex's own fork, appended after every core spawn and tagged 'service'. It is additive to the core contexts and NOT in the whole-level total above; the level's zombie types apply; its spawns draw from the annexes' OWN family pool (SERVICE_FAMILY_POOL: a configured 20 % rat/dog selection share, Blightbelly 5 %, Strainer 8 % (the only pool that enables it: STRAINER_CONTEXTS), no Siren — per-spawn probabilities, not quotas). The seeded roster pass then runs on the finished level (see the seeded roster): it fixes the level's Strainers at EXACTLY ONE on the maps whose seed rolled the Strainer present, and at none on the others, and it decides per level whether Blightbellies and rat/dogs are there at all (the slot rules of the roster-only Screacher and BB list the core contexts, not the annex). The sampled census shows the outcome with the pass applied. Killed annex enemies stay dead for the run (per-index memory).
Service annex (per annex): its own family pool (configured selection share per spawn) — zombie 67 % · blightbelly 5 % · siren 0 % · ratdog 20 % · strainer 8 % · screacher 0 % · bb 0 %. This context's OWN pool: its spawns draw their family from it (the same single roll per spawn, room modifiers and eligibility on top) instead of the level pool. The shares are CONFIGURED selection probabilities per spawn, not quotas: a 5-6-enemy annex may hold none or several; the sampled census shows the placed outcome.
These are targets: the generator can place fewer when it runs out of eligible, spaced floor (see placement rules). The game has no per-area or per-square-metre spawn rate; the count is spread over the eligible areas of the context.
Generator: generateMarketLevel in game/src/gen/market/index.ts:82 (repository access required). ONE continuous level (LevelId 'market'): a calm survivor settlement in a salvaged railway shed where the player's train stops (the platform, six trader stalls, the market square, the housing deck), generated once per level seed. NO enemies: the generator never runs a placement (its one ambient context places [0, 0]), there is no horde pool, no Siren eligibility and no service annex (LEVELS.market.trackExtensions 'none'); its friendly residents are not enemies (never in layout.zombies). The seeded roster pass (ai/enemyRoster.ts applyEnemyRoster) does nothing here: a zombie-free level never holds any enemy family.
The settlement (platform, stalls, square, housing deck): none — a calm pit stop (station): count [0, 0]: a calm settlement, gen/market never asks for a placement run
Enemy families
Every placed spawn is one enemy family. A family's conditional share = weight / Σ weights (denominator 1) is the chance that the per-spawn roll of one placed spawn draws that family. It changes the mix, not how many spawns are placed. The seeded roster then decides whether this level holds each special family at all.
Every placed spawn draws its family independently: roll = enemyRoll(level seed, spawn index) ∈ [0, 1), walked over the pool weights of the spawn's room (the level pool when the room has no modifier), in registry order (the rat/dog keeps the top band; a family at weight 0 — the roster-only Screacher / BB — has no band). A drawn family REPLACES a zombie; it never adds to the count.
| Family | Weight | Conditional share (per-spawn roll) | Expected per level by the per-spawn roll alone (before the roster) | Seeded roster: chance the level's roll includes it | Per level with the roster (sampled) |
|---|---|---|---|---|---|
| Infectedzombie | 0.9 | 0.9 / 1 | 0 | nevera zombie-free level | none: a zombie-free level |
| Blightbellyblightbelly | 0.05 | 0.05 / 1 | 0 | nevera zombie-free level | none: a zombie-free level |
| Sirensiren | 0 | 0 / 1 | 0 | nevera zombie-free level | none: a zombie-free level |
| Tunnel scavenger (rat/dog)ratdog | 0.05 | 0.05 / 1 | 0 | nevera zombie-free level | none: a zombie-free level |
| Strainerstrainer | 0 | 0 / 1level pool; its weight is in a context's own pool: Service annex (per annex) 8% | 0 | nevera zombie-free level | none: a zombie-free level |
| Screacherscreacher | 0 | 0 / 1roster-only: no per-spawn roll draws it (placed by the seeded roster alone) | 0 | nevera zombie-free level | none: a zombie-free level |
| BBbb | 0 | 0 / 1roster-only: no per-spawn roll draws it (placed by the seeded roster alone) | 0 | nevera zombie-free level | none: a zombie-free level |
Expected per level by the per-spawn roll alone = share × spawns tried per level (E = 0), with neutral room
modifiers and before any placement shortfall.
That is the stage before the roster pass. The last two columns are the seeded roster: a level either
holds a family or has none of it, so the per-level figure of a level that holds it is higher than the long-run mean.
Defined at ENEMY_POOL in game/src/ai/spawnTables.ts:125 (repository access required).
Seeded roster
Survivor Market is a zombie-free level: it holds no enemy of any family, and the seeded roster pass does nothing here.
| Family | Can this level hold it | Chance the roll includes it | On this level | The roll itself over level seeds 1 to 10000 | Sample levels with the roster (sampled) |
|---|---|---|---|---|---|
| Infectedzombie | no: a zombie-free level | nevera zombie-free level | Never: Survivor Market is a zombie-free level — it holds no enemy of any family, and the roster pass does nothing there. | not rolled | none: a zombie-free level |
| Blightbellyblightbelly | no: a zombie-free level | nevera zombie-free level | Never: Survivor Market is a zombie-free level — it holds no enemy of any family, and the roster pass does nothing there. | not rolled | none: a zombie-free level |
| Sirensiren | no: a zombie-free level | nevera zombie-free level | Never: Survivor Market is a zombie-free level — it holds no enemy of any family, and the roster pass does nothing there. | not rolled | none: a zombie-free level |
| Tunnel scavenger (rat/dog)ratdog | no: a zombie-free level | nevera zombie-free level | Never: Survivor Market is a zombie-free level — it holds no enemy of any family, and the roster pass does nothing there. | not rolled | none: a zombie-free level |
| Strainerstrainer | no: a zombie-free level | nevera zombie-free level | Never: Survivor Market is a zombie-free level — it holds no enemy of any family, and the roster pass does nothing there. | not rolled | none: a zombie-free level |
| Screacherscreacher roster-only | no: a zombie-free level | nevera zombie-free level | Never: Survivor Market is a zombie-free level — it holds no enemy of any family, and the roster pass does nothing there. | not rolled | none: a zombie-free level |
| BBbb roster-only | no: a zombie-free level | nevera zombie-free level | Never: Survivor Market is a zombie-free level — it holds no enemy of any family, and the roster pass does nothing there. | not rolled | none: a zombie-free level |
There is nothing to sample: a zombie-free level holds no enemy before or after the pass.
Roster version 4; the rules of the pass and every family's rule: the seeded roster.
Defined at applyEnemyRoster in game/src/ai/enemyRoster.ts:285 (repository access required).
Zombie types
Not separate enemy families. The types (coated, shambler) split the Infected family only; the family shares above do not change with them. Wardrobe outfits are a further appearance choice, also not a family.
| Type | Chance per spawn |
|---|---|
| coated | |
| shambler |
Each spawn of a run: coated with the coated chance, else shambler; then, if the run has no coated, its first spawn becomes coated, and (count > 1) if it has no shambler, its second becomes shambler. Ratdogs keep the rolled type but ignore it.
| Context | Spawns in the run (n) | Expected coated share |
|---|---|---|
| Service annex (per annex) | 5 | |
| Service annex (per annex) | 6 |
Shambler / coated type (the profile's zombie type roll) and the wardrobe outfit chosen at spawn time from (level seed, spawn index, type) by ai/wardrobe.ts pickZombieLook — sub-distributions of the zombie family, not separate families.
Defined at ZOMBIE_TYPES in game/src/ai/spawnTables.ts:379 (repository access required).
Baseline placement rules
These are the generator's own rules for where the counted spawns go. Room modifiers at 1× leave every one of them unchanged. They are also why a generated level can hold fewer spawns than its count drew.
The settlement (platform, stalls, square, housing deck): none — a calm pit stop
One run covers: the whole settlement (platform, stalls, square, housing deck). Count per run uniform integer U{0..0} (rng.int, inclusive); E[count] = 0.
Which cells can hold a spawn
- a FLOOR cell of the context's storeys (not the outer border row)
- walking distance from the start ≥ 36 cells (18 m)
- every cell within 1 cell(s) walkable
- not a stair ramp, not in a stair-role area, the area on its own storey
- ≥ 5 m from every keep point of the storey
- the area's effective weight (area weight × room intensity) > 0
| Rule | Value | Unit | In metres |
|---|---|---|---|
| walking distance from the player start | 36 | cells | 18 |
| clear walkable cells around the candidate (radius) | 1 | cells | 0.5 |
| straight-line keep-off from stair / elevator landings, the roof hatch and the ladder foot | 5 | m | 5 |
Which areas are visited first
First matching rule wins (enclosed office rooms and back-of-house rooms otherwise). A relative weight in the weighted area order, multiplied by the room intensity D of its room key (1 when the room has no modifier). Weight 0 = never a candidate.
| Areas matching | Area weight | Why |
|---|---|---|
| kind platform | 2.2 | the platform of the station under the tower |
| type exit-stair / washroom | 0.5 | closed street exits and washrooms |
| type office-stair / stair-core / office-elevator | 0 | never in a stairwell, stair core or the elevator cab |
| type eatery / shop | 0.5 | storefront units |
| kind closet | 0.5 | closets |
| type office-open | 1.6 | open-plan office floors |
| public space | 1 | other public halls, lobby and corridors |
| any other area | 1.3 |
How many spawns one area may hold
The placement walks the area order once per pass (caps 1, 2, 3); an area takes one more spawn per visit while it is below its cap for that pass. Room modifiers never raise a cap.
| Areas matching | Cap | Why |
|---|---|---|
| kind platform | pass cap + 1 | platforms hold one more per pass |
| kind closet | at most 1 | closets: at most one |
| any other area | the pass cap |
- Tries per area visit
- 14 random eligible cells
- Spacing
- at least 4 m between spawns (straight line, same storey)
Placement defined at OFFICE_PLACEMENT in game/src/ai/spawnTables.ts:374 (repository access required).
How a run places its count, and why it can fall short
- Draw count = U{0..0} (one draw per run), then the zombie types of that many spawns.
- Collect every eligible cell, grouped by area; order the areas by a weighted shuffle (Efraimidis–Spirakis keys u^(1/weight)).
- For each cap pass (1, 2, 3), walk the order: an area below its cap gets up to 14 random cell picks; the first pick ≥ 4 m from every enemy already placed on that storey takes one spawn.
- Stop when the count is reached. Spacing, caps and eligible floor can leave a run short of its count (placed < count); validation regenerates the attempt where the profile requires it.
- Each placed spawn is then a family by its own roll (see the family pool) — independent of the area unless a room modifier says otherwise.
Checks that reject a whole generation attempt
- more than 0 placed in one run → the whole attempt is regenerated
- an enemy closer than 36 walking cells to the start, on an unreachable cell or intersecting geometry → the attempt is regenerated
Context defined at MARKET_SPAWN_PROFILE.contexts.station in game/src/ai/spawnTables.ts:802 (repository access required).
Service annex (per annex)
One run covers: none: the market grows no service annex (LEVELS.market.trackExtensions none). Count per run uniform integer U{5..6} (rng.int, inclusive); E[count] = 5.5.
Which cells can hold a spawn
- a FLOOR cell of the context's storeys (not the outer border row)
- walking distance from the start ≥ 36 cells (18 m)
- every cell within 1 cell(s) walkable
- the area's effective weight (area weight × room intensity) > 0
- an area of the zone (one service annex), ≥ 6 m from the annex's entry door (its keep point)
| Rule | Value | Unit | In metres |
|---|---|---|---|
| walking distance from the player start | 36 | cells | 18 |
| clear walkable cells around the candidate (radius) | 1 | cells | 0.5 |
| straight-line keep-off from stair / elevator landings, the roof hatch and the ladder foot | 6 | m | 6 |
Which areas are visited first
First matching rule wins (annex rooms (pump / electrical rooms, stores, workshops, custodial rooms) otherwise). A relative weight in the weighted area order, multiplied by the room intensity D of its room key (1 when the room has no modifier). Weight 0 = never a candidate.
| Areas matching | Area weight | Why |
|---|---|---|
| kind closet | 0.6 | annex closets (janitor / electrical / supply) |
| kind service | 1 | annex service corridors (1.5-2 m wide) |
| any other area | 1.4 |
How many spawns one area may hold
The placement walks the area order once per pass (caps 1, 2); an area takes one more spawn per visit while it is below its cap for that pass. Room modifiers never raise a cap.
| Areas matching | Cap | Why |
|---|---|---|
| kind closet | at most 1 | closets: at most one |
| any other area | the pass cap |
- Tries per area visit
- 12 random eligible cells
- Spacing
- at least 5 m between spawns (straight line)
Placement defined at SERVICE_PLACEMENT in game/src/ai/spawnTables.ts:405 (repository access required).
How a run places its count, and why it can fall short
- Draw count = U{5..6} (one draw per run), then the zombie types of that many spawns.
- Collect every eligible cell, grouped by area; order the areas by a weighted shuffle (Efraimidis–Spirakis keys u^(1/weight)).
- For each cap pass (1, 2), walk the order: an area below its cap gets up to 12 random cell picks; the first pick ≥ 5 m from every enemy already placed takes one spawn.
- Stop when the count is reached. Spacing, caps and eligible floor can leave a run short of its count (placed < count); validation regenerates the attempt where the profile requires it.
- Each placed spawn is then a family by its own roll (see the family pool) — independent of the area unless a room modifier says otherwise.
Checks that reject a whole generation attempt
- more than 6 placed in one run → the whole attempt is regenerated
- an enemy closer than 36 walking cells to the start, on an unreachable cell or intersecting geometry → the attempt is regenerated
Context defined at MARKET_SPAWN_PROFILE.contexts.service in game/src/ai/spawnTables.ts:803 (repository access required).
Room modifiers
All 0 room keys resolve to 1× for every family (neutral); the profile sets no room modifiers. A room key or family without an entry resolves to 1×, which leaves the baseline placement unchanged.
Room key = the area's purpose id (gen/purposes.ts) when it has one, else its room type. Each field resolves: purpose entry → room-type entry → 1 (missing = neutral). Two modifiers exist per room key and family. Density changes local intensity: how strongly the room's areas are preferred when spawns are spread. Weight changes conditional composition: which family a spawn placed in that room is. Neither changes the count range, and caps and spacing still apply. No explicit entries: every other room / family resolves to 1×. Rows list the room keys seen in the sampled census plus any explicit entry; a key not listed resolves to 1× as well.
| Modifier | Changes | How | At 0 | At 2 |
|---|---|---|---|---|
| Density (local intensity) | local intensity | area weight × D, D = all.density × Σ_f p_f·w_f·d_f / Σ_f p_f·w_f (p = pool weight, w = weight modifier, d = density modifier); the room's family mix uses p_f·w_f·d_f | D = 0: the room is never a candidate (no spawns there); the count roll and the other rooms are unchanged, so its spawns go elsewhere when capacity allows. | The room is visited earlier in every cap pass, so it tends to fill its caps before the count runs out: more spawns there, fewer elsewhere, the same total. |
| Weight (conditional composition) | conditional composition | P(family f | spawn lands in the room) = p_f·w_f·d_f / Σ_g p_g·w_g·d_g | That family never spawns in that room (its spawns there become the other families). | Twice its relative odds in that room before normalisation; the room still attracts the same number of spawns. |
The profile sets no explicit room modifier entries: every room key below resolves to the neutral 1×.
| Room key | Key kind | Sampled room types | Room intensity D(room) | Infected: density | Infected: weight | Blightbelly: density | Blightbelly: weight | Siren: density | Siren: weight | Tunnel scavenger (rat/dog): density | Tunnel scavenger (rat/dog): weight | Strainer: density | Strainer: weight | Screacher: density | Screacher: weight | BB: density | BB: weight |
|---|
Room intensity D(room) multiplies the room's baseline area weight (see placement rules). Defined
at roomIntensity in game/src/ai/spawnTables.ts:992 (repository access required). Meaning of each field: room modifiers.
Sampled census
sampled Observed, not a rule. These figures come from running the real Survivor Market generator on a small fixed corpus: 4 generated layouts from seeds 11, 222, 3333, 44444, pistol start. Eligible floor is the floor the generator's own candidate filter accepted (0 cells of 0.25 m², 0 m² in total), not the map's bounding box. Densities are placed spawns per 100 m² of that eligible floor over this sample only. Families are counted with the seeded roster applied: what these levels hold. The roster changes families only, so the totals are the generator's.
SAMPLED: 4 sample levels of the registered generator (seeds 11, 222, 3333, 44444, shipped start weapon) WITH THE SEEDED ROSTER APPLIED (roster version 4: what a level holds; the roster only changes families, so counts, positions and eligible floor are the generator's). Eligible floor = cells the generator's own candidate filter accepted (walking distance, clearance, storey, stair / landing keep-off, weight > 0) x 0.25 m² — never bounding boxes. Not exhaustive; not a runtime rule.
| Family | Placed over the sample (with the roster) | Mean per level | Sample levels that hold it | Per 100 m² eligible floor (sampled) | Placed by the per-spawn roll alone (before the roster pass) |
|---|---|---|---|---|---|
| Infectedzombie | 0 | 0 | 0 of 4 | 0 | 0 |
| Blightbellyblightbelly | 0 | 0 | 0 of 4 | 0 | 0 |
| Sirensiren | 0 | 0 | 0 of 4 | 0 | 0 |
| Tunnel scavenger (rat/dog)ratdog | 0 | 0 | 0 of 4 | 0 | 0 |
| Strainerstrainer | 0 | 0 | 0 of 4 | 0 | 0 |
| Screacherscreacher | 0 | 0 | 0 of 4 | 0 | 0 |
| BBbb | 0 | 0 | 0 of 4 | 0 | 0 |
How to read these numbers
- Count range = intensity: how many spawns one run of a context tries to place, drawn uniformly. E[count] = (lo + hi) / 2.
- Conditional share = weight / Σ weights: the chance that one placed spawn draws that family. It sets the mix, not the number. A family with an eligibility rule places fewer than it draws (measured, sampled).
- Seeded roster = the chance that this level holds a special family at all, rolled once per family from the level seed, after the per-spawn roll. A level has the family or has none of it; the enemy count never changes.
- Area weights and caps decide where spawns go and are not chances. Eligibility, spacing, caps and tries can leave a level with fewer spawns than the count drew.
- Per 100 m² figures are sampled over eligible floor of a named corpus, never a runtime rule.
More: How to read enemy numbers.
Where to tune it
Each value names the source file and export where it lives (the game repository is private).
| Value | Current | Where it lives |
|---|---|---|
| count range (station) | 0 | MARKET_SPAWN_PROFILE.contexts.station.count in game/src/ai/spawnTables.ts:802 (repository access required) |
| count range (service) | 5–6 | MARKET_SPAWN_PROFILE.contexts.service.count in game/src/ai/spawnTables.ts:844 (repository access required) |
| family pool weights | zombie 0.9, blightbelly 0.05, siren 0, ratdog 0.05, strainer 0, screacher 0, bb 0 | ENEMY_POOL in game/src/ai/spawnTables.ts:125 (repository access required) |
| coated chance | 0.4 | ZOMBIE_TYPES in game/src/ai/spawnTables.ts:379 (repository access required) |
| area weights | 7 rules, otherwise 1.3 | OFFICE_AREA_WEIGHTS in game/src/ai/spawnTables.ts:347 (repository access required) |
| caps | passes 1 / 2 / 3; 2 rules | OFFICE_CAPS in game/src/ai/spawnTables.ts:361 (repository access required) |
| tries per area visit | 14 | OFFICE_PLACEMENT.tries in game/src/ai/spawnTables.ts:375 (repository access required) |
| spacing (m) | 4 | OFFICE_PLACEMENT.spacingM in game/src/ai/spawnTables.ts:375 (repository access required) |
| keep-away from the start (cells)18 m walking | 36 | OFFICE_PLACEMENT.startCells in game/src/ai/spawnTables.ts:375 (repository access required) |
| landing keep-off (m) | 5 | OFFICE_PLACEMENT.landingKeepM in game/src/ai/spawnTables.ts:375 (repository access required) |
| area weights | 2 rules, otherwise 1.4 | SERVICE_AREA_WEIGHTS in game/src/ai/spawnTables.ts:387 (repository access required) |
| caps | passes 1 / 2; 1 rules | SERVICE_CAPS in game/src/ai/spawnTables.ts:396 (repository access required) |
| tries per area visit | 12 | SERVICE_PLACEMENT.tries in game/src/ai/spawnTables.ts:406 (repository access required) |
| spacing (m) | 5 | SERVICE_PLACEMENT.spacingM in game/src/ai/spawnTables.ts:406 (repository access required) |
| keep-away from the start (cells)18 m walking | 36 | SERVICE_PLACEMENT.startCells in game/src/ai/spawnTables.ts:406 (repository access required) |
| landing keep-off (m) | 6 | SERVICE_PLACEMENT.landingKeepM in game/src/ai/spawnTables.ts:406 (repository access required) |
| room modifiersroom key → family (or all) → {density, weight} | none (all 1×) | MARKET_SPAWN_PROFILE.rooms in game/src/ai/spawnTables.ts:805 (repository access required) |
| difficulty tiermetadata only (no scaling) | 1 | LEVELS.market.tier in game/src/levels/registry.ts:106 (repository access required) |