Difficulty picker (Easy/Normal/Hard) and a balance pass
Difficulty: - TD.DIFFICULTIES (starting credits, lives, enemy hp/shield, kill reward), validated create-room / newgame option, state carries it; solo menu picker and co-op lobby picker (44px segmented control, reachable on every layout), HUD/room/end-screen labels, best-wave record per map AND difficulty (Normal keeps the legacy key), Play again keeps the running game's difficulty for host and guest Balance (12 bot runs, deterministic, 48/48 games replay identically in QA): - Normal ~71% bot wins at wave 30 (was 94%), Easy 100%, Hard 25% on open - credits tamed: reward growth 3% -> 2% per wave, clear bonus 10+2n -> 10+n, hp scaling eased, Rootkit pays 60 (was 100) but is tougher, flyers slower; unspent credits at wave 30: 1309 -> 335 - IDS Sniper is now a slow heavy hitter (essential, no longer sufficient: IDS-only dies by wave 7); Mortar, Arc and Filter buffed - Orbital Uplink price step per owned unit 30% (buy and upgrade) - remaining imbalances documented in docs/BALANCE.md Tests: difficulty (19) and balance (8) unit suites, 14-difficulty e2e, layout matrix reachability of the picker. 156 unit tests, 17 e2e scenarios. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tb8pW2KAN4oFkh1aK1BfD8
This commit is contained in:
parent
28502984ec
commit
b4ae6cb57d
19 changed files with 1348 additions and 156 deletions
205
docs/BALANCE.md
205
docs/BALANCE.md
|
|
@ -1,21 +1,165 @@
|
|||
# Balance notes (baseline measured 2026-10-09, nothing tuned yet)
|
||||
# Balance notes (tuned 2026-10-10, wave 4 pass; the untuned baseline was measured the same day)
|
||||
|
||||
`public/js/sim.js` still holds my first-guess numbers. A balance engineer agent built `tools/bot.js` (a headless player that
|
||||
drives the sim through `sim.cmd()` / `sim.preview()`) and measured the untouched numbers; it was stopped before it applied any
|
||||
tuning. `test/sim.test.js` was already updated by it so that no test hard-codes a tunable number (they derive values from
|
||||
the `TOWERS` / `ENEMIES` tables), plus one test that pins the table *shape* the client and server depend on.
|
||||
`public/js/sim.js` holds the tuned tables. The numbers were measured with `tools/bot.js`, a headless player that drives the sim
|
||||
through `sim.cmd()` / `sim.preview()`. No test pins a tuned number: `test/sim.test.js` and `test/difficulty.test.js` derive values
|
||||
from the tables, and `test/balance.test.js` pins the *design rules* the pass relied on (credit budget, boss pay, upgrade
|
||||
efficiency, IDS role, Uplink price share, difficulty ladder), each derived from the tables too.
|
||||
|
||||
The pass was time-boxed (12 runs of the bot, counting two short smoke tests of the tool itself; 8 seeds per cell in the final ones). With 8 seeds one win more or less is 12 points:
|
||||
read the tables as bands, not as exact rates.
|
||||
|
||||
## What a player should notice
|
||||
|
||||
* Kill money is smaller and flatter: a defence earns about 22% fewer credits over 30 waves (7676 -> 5980), a boss is worth
|
||||
about half as much, and the clear bonus grows by 1 a wave instead of 2. Packet hit points are 14 to 21% lower than before
|
||||
(they scale slower), which pays the credit cut back: Normal stays winnable, but no longer by a wide margin.
|
||||
* The IDS Sniper is now a slow heavy sniper (fewer, harder shots): the same damage per second as before against a tank, worse
|
||||
against a swarm of weak packets, so a defence made of IDS alone dies in the first swarm waves. It is still the backbone of
|
||||
every strong build against bosses and armour.
|
||||
* Mortar, Arc and Filter are better value; upgrades are cheaper for them (and dearer for the IDS), so credits go into
|
||||
upgrading and into a mix.
|
||||
* Flyers are slower (longer in range), Trojans and Rootkits are more armoured, the opening waves are unchanged.
|
||||
|
||||
## Constants changed, and why (all in `public/js/sim.js`)
|
||||
|
||||
| constant | before | after | reason |
|
||||
|---|---|---|---|
|
||||
| `rewardScale(n)` | 1 + 0.03 (n-1) | 1 + 0.02 (n-1) | late kills paid too much; credits snowballed |
|
||||
| Rootkit `reward` | 100 | 60 | a boss wave paid the price of ~2 IDS; now about one (wave 10: 127 -> 71 credits, wave 30 with 3 bosses: 561 -> 285) |
|
||||
| Rootkit `buyCost` | 300 | 180 | keeps the "about 3x the kill reward" rule of the future versus mode (`docs/VERSUS.md` number updated) |
|
||||
| clear bonus | 10 + 2 n | 10 + n (`CLEAR_BONUS`, `CLEAR_BONUS_PER_WAVE`, `clearBonus(n)` exported) | the bonus alone was 16% of all credits; only constants were extracted, the formula is the same |
|
||||
| `hpScale(n)` | 1 + 0.16 (n-1) + 0.022 (n-1)^2 | 1 + 0.145 (n-1) + 0.0165 (n-1)^2 | pays back the credit cut: 14% lower at wave 10, 19% at 20, 21% at 30 than the untuned game |
|
||||
| Trojan `armor` | 3 | 4 | armour should matter a little more against Filters |
|
||||
| Rootkit `armor` | 5 | 7 | same, and the boss is the IDS / Mortar / Uplink job |
|
||||
| Spoof (ghost) `speed` | 1.6 | 1.3 | flyers ignore the maze, so they get little time in range; they were a cliff at waves 7, 13, 15, 23 |
|
||||
| Botnet `speed` | 2.6 | 2.2 | same |
|
||||
| IDS cost (L1/L2/L3) | 60 / 70 / 110 | 70 / 80 / 130 | the best tower per credit by far; 58 of them were built per game |
|
||||
| IDS dmg | 50 / 85 / 150 | 83 / 143 / 250 | same dps against a tank as before... |
|
||||
| IDS rate | 0.70 / 0.75 / 0.80 | 0.42 / 0.445 / 0.48 | ...but fewer shots, so swarms of weak packets are not its job (IDS-only now dies by wave 7) |
|
||||
| IDS range | 6.5 / 7.2 / 8.0 | 6.2 / 6.8 / 7.5 | slightly less coverage per credit |
|
||||
| IDS description | "...bosses." | "...bosses, poor against swarms." | the player is told |
|
||||
| Filter range | 3.2 / 3.5 / 3.9 | 3.5 / 3.8 / 4.2 | the cheap swarm / anti-air tower had too little coverage |
|
||||
| Filter upgrade cost (L2/L3) | 30 / 55 | 25 / 45 | an upgrade gave 58% of the dps per credit of a new tower |
|
||||
| Mortar cost / dmg / range | 55 60 100 / 28 45 75 / 4.8 5.2 5.6 | 55 60 95 / 31 50 82 / 4.9 5.3 5.7 | far too weak; now the answer to ground swarms |
|
||||
| Arc cost / dmg | 75 70 120 / 16 24 36 | 70 60 105 / 17 26 38 | far too weak alone; the first buff (dmg 20 30 44, 65 / 50 / 90) let Arc-only win 6 of 8 on `open`, so this is the middle |
|
||||
| Arc range | 3.6 / 3.8 / 4.2 | 3.8 / 4.0 / 4.4 | |
|
||||
| `DIFFICULTIES.hard` | gold 0.8, lives 0.7, hp 1.3, reward 0.9 | gold 0.9, lives 0.85, hp 1.08, reward 0.97 | the first row was a wall (0 wins in 35 games). The whole row (+8% hp, -3% rewards, -10% credits, -15% lives) takes `open` from 75% to 25% |
|
||||
| `DIFFICULTIES.easy` | 1.5 / 1.5 / 0.8 / 1.1 | unchanged | already 56 of 56 |
|
||||
|
||||
Not changed: `START_GOLD` 140, `START_LIVES` 20, `WAVE_INTERVAL` 28, `SELL_RATIO` 0.7, every `waveGroups` count and gap, Throttle,
|
||||
Sandbox, Load Balancer, and the Orbital Uplink (1500 / 1200 / 2000 / 3200, each owned Uplink makes the next one and its
|
||||
upgrades 30% dearer: the user's request, kept). Wall price and wall count are untouched on purpose (user decision: the maze stays strong).
|
||||
|
||||
## Results (Normal unless stated; "win" = the wave 30 clear)
|
||||
|
||||
Before = the untuned numbers, 5 seeds. After = the shipped numbers, 8 seeds (Easy and Hard rows: `maze@easy`, `maze@hard`).
|
||||
|
||||
| mixed maze bot | before | after | target |
|
||||
|---|---|---|---|
|
||||
| open | 4/5 | 6/8 | 70-80% |
|
||||
| twin | 5/5 | 5/8 | 50-70% |
|
||||
| hub | 5/5 | 6/8 | 40-50% |
|
||||
| canyon | 5/5 | 8/8 | 50-70% |
|
||||
| archipelago | 5/5 | 5/8 | 50-70% |
|
||||
| fortress | 4/5 | 5/8 | 50-70% |
|
||||
| pinwheel | 5/5 | 5/8 | 40-50% |
|
||||
| all maps | 33/35 (94%), 12-20 lives left | 40/56 (71%), 12 lives left (open 10) | about 58% |
|
||||
| Easy, all maps | 35/35 | 56/56 (27-30 lives left of 30) | 90%+ |
|
||||
| Hard, open / twin / hub | 0/35 on all maps (dies wave 7-29) | 2/8 / 1/8 / 0/8 (mean wave 25.6 / 21.5 / 20.9) | 20-35% on open |
|
||||
|
||||
| single-tower and ablation builds (8 seeds) | before | after |
|
||||
|---|---|---|
|
||||
| spam-ids (open+twin) | 35/35 (all maps) | 0/16, dies in wave 3-7 (swarm waves) |
|
||||
| spam-filter (open+twin) | 0/35 (all maps), wave 12-23 | 0/16, wave 12-22 |
|
||||
| spam-mortar (open, twin, hub) | 0/24, wave 6-8 (old doc) | 0/16 (open, twin), wave 6-8 (flyers: no anti-air) |
|
||||
| spam-arc (open, twin, hub) | 0/24, wave 14-22 (old doc) | 0/16 (open, twin), wave 15-26 |
|
||||
| mixed without IDS (open) | 0/5, dies wave 16-29 | 1/8 (mixed: 6/8) |
|
||||
| mixed without Mortar (open) | not measured | 1/8 |
|
||||
| mixed without Throttle (open) | not measured | 2/8 |
|
||||
| mixed without Arc (open) | not measured | 6/8 |
|
||||
| mixed without Filter (open) | not measured | 8/8 |
|
||||
|
||||
| economy (mixed bot) | before | after |
|
||||
|---|---|---|
|
||||
| credits paid by wave 10 / 15 / 20 / 25 / 30 (gold + invested, games that got that far, all maps) | 874 / 1551 / 2370 / 3560 / 6577 | 773 / 1320 / 2040 / 2860 / 5190 |
|
||||
| credits in hand at wave 10 / 15 / 20 / 25 | 33 / 39 / 33 / 38 | 32 / 33 / 33 / 30 (always spent) |
|
||||
| credits in hand at wave 30 (the bot stops buying when no wave is left to prepare for) | 1309 | 335 |
|
||||
| full-clear income to wave 30 (table arithmetic, `income()` in `test/balance.test.js`) | 7676 | 5980 |
|
||||
| IDS towers at wave 30 (open / twin / hub) | 58 / 49 / 44 (80-97% of all damage) | 25 / 30 / 25 (49% / 76% / 69%) |
|
||||
| lives lost in waves 1-5 (sum over games) | 5 in 35 games | 3 in 56 games |
|
||||
|
||||
Where the lives go (mixed bot, all maps): Rootkit leaks (5 lives each) 66% before and 53% after; then Trojans 15%, Spoofs 10%,
|
||||
Proxies 9%, Botnets 6%, Worms 5% (after).
|
||||
|
||||
## Targets scorecard
|
||||
|
||||
| target | state |
|
||||
|---|---|
|
||||
| maze beats no-maze, no-maze survives the first 8-10 waves, lazy dies early, no leaks in waves 1-5 | holds (8 seeds): mixed maze 6/8, 5/8, 6/8 on open / twin / hub against no-maze 1/8, 0/8, 0/8 (they die at wave 21-30, on hub all 8 in the wave 30 boss wave); lazy dies in wave 9 / 4 / 7; waves 1-5 lose 3 lives in 56 games |
|
||||
| Normal open 70-80% | 75% (6/8) |
|
||||
| twin, new maps 50-70% | twin 63, archipelago 63, fortress 63; **canyon 100%** |
|
||||
| hub, pinwheel 40-50% | 75% and 63%: a little easy (not fixable with global tables, see below) |
|
||||
| every spam strategy loses | **yes**, all four 0/16 |
|
||||
| each tower type matters in the best mix | IDS (1/8 without), Mortar (1/8), Throttle (2/8): yes. **Filter and Arc: no** (the mix wins as often, or more, without them) |
|
||||
| credits neither pile up nor starve | spent to the credit at every wave up to 25 (30-33 in hand), 335 at wave 30 (1309 before) |
|
||||
| Easy 90%+, Hard 20-35% on open | 100%, 25% |
|
||||
|
||||
## Remaining known imbalances
|
||||
|
||||
1. **Filter and Arc do not pull their weight in the bot's best build.** Without Filters the mixed build wins 8/8 (with: 6/8)
|
||||
on `open`; the bot over-buys them (23 on `open` at wave 30, 18% of damage) because its surrogate overrates cheap towers. The
|
||||
bot buys almost no Arc (0 to 1.5 a game), though an Arc-only build now reaches wave 15-26. Either the towers still need a
|
||||
role (Arc: chain on dense late swarms, Filter: early game and flyers) or the bot's model undervalues them; a human playtest
|
||||
should decide. Throttle matters (2/8 without it).
|
||||
2. **IDS is still the backbone**: 49 to 76% of the damage of the mixed builds and a build without it wins 1/8, but it is no
|
||||
longer sufficient (IDS-only dies in wave 3-7). A mixed build with ~25 IDS and a handful of Mortars is what the bot finds best.
|
||||
3. **Map spread is not tunable with global tables.** `canyon` (rating 1) is a 100% map, `hub` and `pinwheel` are easier than
|
||||
asked, `archipelago` and `fortress` are about right. Hard is tuned to `open` (25%): on `twin` and `hub` it is 0 to 12%.
|
||||
4. **Boss leaks decide games**: a Rootkit that gets through costs 5 of 20 lives and is the main cause of death. They are
|
||||
dangerous on purpose (the user wanted bosses to hurt); if playtests find it too swingy, lower the Rootkit `leak` to 4 before
|
||||
touching hp. Rootkits walk about 200 s through a long maze, so they overlap 6 to 7 later waves when waves are called on the
|
||||
28 s timer: the bot's per-wave life-loss log attributes such a leak to the wave that was current when it happened.
|
||||
5. **Sandbox, Load Balancer and Orbital Uplink are not valued well by the bot.** It never builds a Sandbox and rarely a Load
|
||||
Balancer, so nothing can be said about them from the numbers. The Uplink was tested with a "save for it" rule: a bot that
|
||||
saves from wave 12 to 16 starves its defence and dies (1/8, mean wave 18.6) before it can pay 1500. Judged on paper: the
|
||||
first Uplink is 1500 = 25% of the 5980 credits a full run pays (the second 1950, the third 2540), and 1500 credits of IDS L1
|
||||
is ~21 towers; the Uplink is an endless-mode purchase, not a way to win wave 30. Nothing was changed.
|
||||
6. The waves were not touched. Flyer waves (`(n-1) % 8` = 4 and 6; from wave 14 with the Botnet swarm) and wave 28 are
|
||||
still where defences break first; the Daemon, Proxy and Botnet themselves are not a leading cause of lost lives
|
||||
(1 to 15% of leaks each).
|
||||
7. The balance of Normal, Easy and Hard is steep: the whole Hard row (8% more packet hit points, 3% less pay, 10% fewer opening
|
||||
credits, 15% fewer lives) moves `open` from 75% to 25%. Re-measure after *any* number change, with at least 8 seeds.
|
||||
|
||||
## Re-running the measurement
|
||||
|
||||
```bash
|
||||
node tools/bot.js --maps open,twin,hub \
|
||||
--strategies maze,nomaze,spam-filter,spam-ids,spam-mortar,spam-arc,lazy,maze-no-ids,maze-no-filter,maze-no-mortar,maze-no-throttle,maze-no-arc \
|
||||
--seeds 8 --max 45
|
||||
```
|
||||
(runs on all cores; `--sim other/sim.js` measures another copy; `--json out.json --detail` for raw games.) Strategies: `maze`
|
||||
(the mixed build), `nomaze`, `spam-<type>` (maze + one turret type), `maze-no-<type>` (ablation), `lazy`.
|
||||
node tools/bot.js --maps open,twin,hub,canyon,archipelago,fortress,pinwheel \
|
||||
--strategies "maze;maze@easy#open;maze@hard#open;maze-no-ids#open;maze-no-filter#open;maze-no-mortar#open;maze-no-arc#open;maze-no-throttle#open;spam-ids#open+twin;spam-arc#open+twin;spam-filter#open+twin;spam-mortar#open+twin" \
|
||||
--seeds 8 --max 30 --verbose --json out.json
|
||||
|
||||
## Baseline results (8 seeds, waves up to 45; "win" = survived to wave 45)
|
||||
# the Easy (all maps) and Hard (open, twin, hub) rows of the results table
|
||||
node tools/bot.js --maps open,twin,hub,canyon,archipelago,fortress,pinwheel \
|
||||
--strategies "maze@easy;maze@hard#open+twin+hub" --seeds 8 --max 30 --verbose --json out-diff.json
|
||||
```
|
||||
|
||||
(about 3 to 10 minutes on 6 cores; it uses all of them. `--sim other/sim.js` measures another copy; `--json out.json --detail`
|
||||
for raw games; `--gold N` overrides the opening credits.) Strategy names: `maze` (the mixed build), `nomaze`, `spam-<type>`,
|
||||
`maze-no-<type>`, `lazy`, `full` (mixed + Sandbox + Load Balancer + Uplink) and `maze+<type>` (mixed + one extra type), with
|
||||
optional `:key=value` overrides (see `DEFAULTS` in the bot; use `;` between strategies that carry them). A strategy can carry a
|
||||
game difficulty after `@` and the only maps it runs on after `#` (`maze@hard#open+twin`). The tables now print `gold@25` and a
|
||||
"credits seen" block (gold + everything invested, games that reached the wave only). Tips: results depend on the bot's own
|
||||
heuristics as much as on the numbers; `full` and `maze+uplink` save for the Uplink from wave 16 (12 with the override), which starves the
|
||||
defence, so do not read their rows as balance data; the bot waits for each wave to clear but calls the next one after at most 28 s; for a
|
||||
Uplink experiment `maze+uplink:uplinkFrom=12` makes it save for one from that wave.
|
||||
|
||||
The bot is deterministic: the same sim and the same seeds replay the same games, so every number above can be reproduced exactly
|
||||
(an independent QA re-run of `maze`, `maze@easy` and `maze@hard` on open / hub / canyon, seeds 1-6, matched all 48 recorded games
|
||||
move for move, outcome and lives left). `maze@hard` on `canyon` was not measured in the pass: 4 of 6 won in the QA re-run.
|
||||
|
||||
The bot's model of the support towers is crude: a Sandbox counts as a slow of `stun / pulse`, a Load Balancer as a fire-rate boost
|
||||
on the turrets in its range, the Uplink as armour-ignoring damage with a pierce factor. Treat their rows as "not measured".
|
||||
|
||||
## The untuned baseline (for the record; 8 seeds, waves up to 45, 2026-10-09)
|
||||
|
||||
| strategy | open | twin | hub |
|
||||
|---|---|---|---|
|
||||
|
|
@ -26,39 +170,8 @@ node tools/bot.js --maps open,twin,hub \
|
|||
| spam-mortar | 0/8 (wave 8) | 0/8 (wave 6-8) | 0/8 (wave 6-7) |
|
||||
| spam-arc | 0/8 (wave 14-22) | 0/8 | 0/8 |
|
||||
| maze without IDS | 0/8 (wave 14-29) | 0/8 | 0/8 |
|
||||
| maze without filter / throttle / arc | still wins (7-8 of 8) | still wins (7-8 of 8) | still wins (7-8 of 8) |
|
||||
| lazy | dies wave 8-9 | wave 3-4 | wave 6 |
|
||||
|
||||
Route length at wave 30 with the maze strategy, per gateway: about 150 cells on open, ~165 on twin and ~136 on hub, versus
|
||||
roughly 25 for the unobstructed path (the bot reports the sum over gateways: 150 / 330 / 409). Credits at wave 30: about 280 unspent.
|
||||
|
||||
## What the numbers say
|
||||
|
||||
1. **IDS Sniper is mandatory and sufficient.** Every build without it collapses around wave 15-28; a maze + IDS-only
|
||||
build wins everything on every map. That breaks the design goal that no single tower dominates and that flyers/armour
|
||||
force a mixed defence. IDS needs a cost/damage/range nerf, or the other towers need real roles (Mortar and Arc are
|
||||
far too weak on their own: they die by wave 8 / 15-22).
|
||||
2. **The maze is a near-guaranteed win.** Cheap 5-credit walls stretch routes about 5 to 6 times, and the game is too easy
|
||||
once you do it. Mazing should be rewarding but not a solved game. Candidate levers (a design decision, see NEXT.md):
|
||||
escalating wall price (for example +1 credit per 10 walls), a wall cap, faster late waves, or armour/regen that punishes
|
||||
long exposure.
|
||||
3. **No-maze is too viable on open** (reaches wave 29-43). Early waves are too gentle, or turrets too strong without a maze.
|
||||
4. **Economy snowballs** (about 280 credits unspent at wave 30) while the early game is tight (about 30-45 credits spare
|
||||
around waves 5-10). Cut late-game rewards or add sinks (upgrade costs, escalating prices).
|
||||
5. Throttle, Filter and Arc individually add little (removing any one still wins): either buff their roles or accept they
|
||||
are support pieces.
|
||||
|
||||
## Targets the tuning should hit (from the original brief)
|
||||
|
||||
* Maze clearly beats no-maze; no-maze still survives the first 8-10 waves; lazy dies early.
|
||||
* On `open`, a good maze build wins wave 30 in most seeds with a few lives to spare but not with a perfect record; no leaks
|
||||
in waves 1-5.
|
||||
* `twin` harder than `open`; `hub` hardest (maze build reaching roughly waves 24-30).
|
||||
* Every single-tower spam strategy loses before wave 30 on `open`; every tower type is part of the best mixed build at least
|
||||
sometimes. Flyer waves must punish a defence without anti-air, boss/Trojan waves must punish pure Filter spam.
|
||||
* Credits neither snowball nor starve.
|
||||
|
||||
Only constants and tables in `sim.js` should need to change (costs, damage, range, rates, enemy hp/speed/armor/reward,
|
||||
`waveGroups` counts, `hpScale`, `rewardScale`, `START_GOLD`, `SELL_RATIO`). Keep every table key, the 3-entry `levels`
|
||||
arrays and the field names: the client UI and the server read them. A wall price escalation would be a logic change in
|
||||
`Sim.place` and in the client's cost display.
|
||||
Its findings: IDS mandatory and sufficient; the maze a near-guaranteed win; no-maze too viable on `open`; the economy snowballed
|
||||
(about 280 credits unspent at wave 30 and ~60 IDS per game) while the early game was tight. This pass answered them with the
|
||||
credit cut, the sniper role for the IDS and better Mortar / Arc / Filter value; the wall rule was ruled out by the user.
|
||||
|
|
|
|||
20
docs/NEXT.md
20
docs/NEXT.md
|
|
@ -3,18 +3,18 @@
|
|||
Netwall is playable and pushed: solo (desktop + phone), two-player co-op through the Node server, music, PWA, deploy docs.
|
||||
Development was paused on purpose before the fix stage. This file is the entry point for the next session.
|
||||
|
||||
## State of the repo
|
||||
## State of the repo (2026-10-11)
|
||||
|
||||
| Area | State |
|
||||
|---|---|
|
||||
| `public/js/sim.js` | Shared rules. 20 unit tests. **Balance not tuned yet** (see `docs/BALANCE.md`). |
|
||||
| `server/` | Done and reviewed by an independent adversarial pass (5 real issues found and fixed: pid leak/slot hijack, room-flood lockout, spoofable X-Forwarded-For, startup crash in restricted sandboxes, clock-step in rate limiter). 59 tests. |
|
||||
| `public/` client | Works, but a second review pass found many issues. **None fixed yet.** See `docs/review-2026-10-09/findings.md`. |
|
||||
| `e2e/` | `npm run e2e`: smoke, touch, end flow, co-op (two browsers incl. reconnect), 14-size layout matrix. All passed at the last run. |
|
||||
| `tools/bot.js` | Headless balance bot (dev tool). Complete; its results are summarised in `docs/BALANCE.md`. |
|
||||
| Deploy | `docs/DEPLOY.md`, `deploy/netwall.service`, README setup guide. Never run against a real nginx Proxy Manager or on a phone yet (an NPM-style review found doc inaccuracies, listed in the findings). |
|
||||
| `public/js/sim.js` | Shared rules: 7 maps, 9 towers (Sandbox, Load Balancer, 4-level Orbital Uplink with escalating prices), 9 enemy kinds, Easy/Normal/Hard. **Balance tuned once** (Normal ~71% bot wins, see `docs/BALANCE.md`); remaining imbalances are listed there. |
|
||||
| `server/` | Adversarially reviewed (pid leak, room flood, XFF, ...) and proxy-tested against real nginx with Proxy Manager's config. Co-op robustness fixed (stalls, half-open sockets, idempotent commands). |
|
||||
| `public/` client | Phone-first layout (action bars, scrollable palette, pinned overlay footers), touch precision (nothing commits on pointerdown, nudge arrows), a11y/audio fixes, difficulty picker. Tested across 33 viewports incl. tablets and foldables (emulated). |
|
||||
| `e2e/` | `npm run e2e`: 17 scenarios (smoke, touch, touch precision, select/sell, info-panel stability, UI states, a11y, audio, content gallery, co-op chaos, session UI, Uplink price, difficulty, 33-layout matrix ~8 min). Timing checks can flake on a loaded machine: rerun a scenario alone before concluding anything. |
|
||||
| `tools/bot.js` | Headless defender bot (dev tool; deterministic). Does not build Sandbox / Load Balancer / Uplink. |
|
||||
| Deploy | `docs/DEPLOY.md`, `deploy/netwall.service`, README setup guide; proxy behaviour verified against nginx 1.26 with Proxy Manager v2.16's rendered config (not the NPM app itself, not a real LXC). |
|
||||
|
||||
`npm test` = 91 passing. `npm run e2e` = 9 scenarios (22-layout matrix, touch precision, selection/sell, info-panel stability, UI states, co-op). Verified from a fresh `git clone` earlier (2026-10-09).
|
||||
`npm test` = 156 passing.
|
||||
|
||||
## Fixed since this was written
|
||||
|
||||
|
|
@ -31,8 +31,8 @@ and a check that the layout holds on **tablets and foldables**.
|
|||
|---|---|---|
|
||||
| 1 | Phone panels/layout + touch precision, proxy/server doc fixes, QA | **done 2026-10-10** |
|
||||
| 2 | Co-op robustness (stalled-render tower loss, half-open sockets, idempotent upgrade/wave, restart message), audio + keyboard + a11y | **done 2026-10-10** (QA passed) |
|
||||
| 3 | New enemies (Daemon healer, Proxy shielded, Botnet swarm) and towers (Sandbox stun, Load Balancer buff), glyphs/shapes, gallery e2e; Orbital Uplink (4 levels, priced 1500 + 25% per owned, upgrades scale equally); 4 new maps | **done 2026-10-10** (QA passed) |
|
||||
| 4 | Difficulty picker (Easy/Normal/Hard) + ONE time-boxed balance pass (IDS dominance, weak Mortar/Arc, credit snowball and boss rewards, new content) | drafted (`wave4d`) |
|
||||
| 3 | New enemies (Daemon healer, Proxy shielded, Botnet swarm) and towers (Sandbox stun, Load Balancer buff), glyphs/shapes, gallery e2e; Orbital Uplink (4 levels, priced 1500 + 25% per owned, upgrades scale equally; ); 4 new maps | **done 2026-10-10** (QA passed) |
|
||||
| 4 | Difficulty picker (Easy/Normal/Hard) + ONE time-boxed balance pass (IDS no longer sufficient, credit snowball tamed, Mortar/Arc/Filter buffed, flyers slower); Uplink price step set to 30% per owned | **done 2026-10-11** (QA passed) |
|
||||
| 5 | Attack-vs-defend versus mode, bots for both sides | design in `docs/VERSUS.md`, workflow drafted |
|
||||
| 6 | Server leaderboard (needs `StateDirectory=netwall` + `DATA_DIR`; solo scores are client-reported) and an opt-in public room list | after 5 |
|
||||
| any | Fold/tablet real-device check; open items below | |
|
||||
|
|
|
|||
|
|
@ -78,16 +78,20 @@ at a domain root and under a path prefix the proxy strips.
|
|||
Client's first message:
|
||||
|
||||
```
|
||||
{ t:'join', pid, name, room?, map? }
|
||||
{ t:'join', pid, name, room?, map?, difficulty? }
|
||||
```
|
||||
* `pid` `^[A-Za-z0-9_-]{8,40}$` - random, generated by the client, kept in `sessionStorage` (stable across reloads).
|
||||
* `name` any string; server trims, strips control chars, caps at 16 chars, default `"Player"`.
|
||||
* `room` absent -> **create** a room. `map` must be a key of `TD.MAPS` (default `'open'`).
|
||||
* `room` absent -> **create** a room. `map` must be a key of `TD.MAPS` (default `'open'`). `difficulty` must be a key of
|
||||
`TD.DIFFICULTIES` (`'easy'`, `'normal'`, `'hard'`; default `'normal'`, `null` counts as absent), see "Difficulty" below.
|
||||
Server generates a 4 character code from `ABCDEFGHJKLMNPQRSTUVWXYZ23456789`, unique among rooms.
|
||||
* `room` present (`^[A-Za-z0-9]{4}$`, case-insensitive -> upper-cased) -> **join**.
|
||||
* `room` present (`^[A-Za-z0-9]{4}$`, case-insensitive -> upper-cased) -> **join**. `map` and `difficulty` are ignored on a join (not even
|
||||
validated): the joiner gets the room's, in `state.map` / `state.difficulty` of the `joined` message. A reconnect (same `pid`) is a join.
|
||||
|
||||
Failure: `{ t:'error', code, msg }` then the server closes the socket (code 4000+).
|
||||
Codes: `bad_request`, `no_room`, `full` (two *other* pids already hold the slots), `too_many_rooms`, `bad_map`.
|
||||
Codes: `bad_request`, `no_room`, `full` (two *other* pids already hold the slots), `too_many_rooms`, `bad_map`, `bad_difficulty`
|
||||
(a creating join whose `difficulty` is not one of the table's keys: wrong type, `'toString'`, `'__proto__'`, ... all refused, no room is
|
||||
created, the socket closes with 4400; a bad `map` is checked first).
|
||||
|
||||
Success: reply to the joiner
|
||||
|
||||
|
|
@ -121,7 +125,7 @@ pid for the viewer's own entry and an opaque, stable per-room alias for the othe
|
|||
| `{t:'mark', x, y}` | map ping; at most 1 per 400 ms per player; server broadcasts `mark` (below) |
|
||||
| `{t:'rtt', ts}` | latency probe; reply immediately with the same `ts` |
|
||||
| `{t:'sync'}` | ask for a full state resend |
|
||||
| `{t:'newgame', map}` | **host only**: replace the sim with a fresh `new Sim({map})`; resets pause/speed |
|
||||
| `{t:'newgame', map?, difficulty?}` | **host only**: replace the sim with a fresh `new Sim({map, difficulty})`; resets pause/speed. An absent (or `null`) `map` / `difficulty` keeps the room's current one, so a plain `{t:'newgame'}` is "play again" |
|
||||
| `{t:'leave'}` | leave now |
|
||||
|
||||
**Idempotent `upgrade` and `wave`.** Two players who press Upgrade (or Next wave) at the same moment both send the command; without
|
||||
|
|
@ -137,7 +141,8 @@ Command validation is the server's job: `t:'cmd'` must carry a string `c` in the
|
|||
`c`, non-object, etc. count as malformed. A command the sim refuses (`{ok:false, reason}`) gets
|
||||
`{ t:'reject', c, reason, x?, y?, id? }` sent **to the sender only** (echo `x,y`/`id` when present).
|
||||
Successful commands send nothing extra; the effect arrives via `snap`.
|
||||
`newgame` from a non-host -> `reject` with `reason:'not_host'`; `newgame` with a bad map -> `reject` `bad_map`.
|
||||
`newgame` from a non-host -> `reject` with `reason:'not_host'`; `newgame` with a bad map -> `reject` `bad_map`; with a bad difficulty
|
||||
-> `reject` `bad_difficulty` (checked in the order not_host, bad_map, bad_difficulty; a rejected `newgame` changes nothing and sends no `state`).
|
||||
|
||||
## Client behaviour that the protocol relies on
|
||||
|
||||
|
|
@ -167,6 +172,9 @@ Successful commands send nothing extra; the effect arrives via `snap`.
|
|||
{ t:'reject', c, reason, ... }
|
||||
{ t:'error', code, msg }
|
||||
```
|
||||
* `state.difficulty` (also in the `joined` message) is the room's difficulty id. It is a field of `fullState()`, added next to `map`,
|
||||
`rev`, `towers`, `winWave` and `maxLives`; an older server sends none and a client then assumes `'normal'`. The per-tick `snap` does
|
||||
not repeat it: it cannot change without a `state` message (only the host's `newgame` changes it, and that sends one).
|
||||
* `seq` increments by 1 per snapshot per room.
|
||||
* Snapshots are sent every `1000/snapshotHz` ms **whether or not** the sim advanced (paused rooms still send, so
|
||||
cursors keep moving) but only to online players, and only if at least one player is online.
|
||||
|
|
@ -183,6 +191,21 @@ Successful commands send nothing extra; the effect arrives via `snap`.
|
|||
* Because WebSocket is reliable and ordered, `tw` deltas cannot be lost; `snap.rev` lets a client detect a
|
||||
bug/desync (`rev` differs from the `rev` it last applied and no `tw` came along) and ask for `sync`.
|
||||
|
||||
## Difficulty
|
||||
|
||||
`TD.DIFFICULTIES` (`sim.js`) has one row per difficulty, `{ id, name, gold, lives, hp, reward }`, every number a multiplier on the normal
|
||||
game; `TD.DIFFICULTY_ORDER` is `['easy', 'normal', 'hard']` (append-only: the ids are on the wire). `new Sim({ map, difficulty })`:
|
||||
|
||||
* `gold`, `lives`: the starting credits and integrity are `START_GOLD` / `START_LIVES` times it (rounded, integrity at least 1;
|
||||
`state.maxLives` follows). An explicit `gold` / `lives` option of the Sim (tests, the balance bot) is used as given.
|
||||
* `hp`: the hit points of every enemy **and its shield**, so the snapshot's `hp + shield` / `maxhp + maxShield` encoding (the client splits
|
||||
the two by the kind's base ratio) stays right.
|
||||
* `reward`: what a kill pays (at least 1). The wave clear bonus and the tower prices do not change.
|
||||
* An unknown value in `new Sim` is `'normal'`; the server refuses it (`bad_difficulty`) instead.
|
||||
|
||||
Normal is all 1: it plays the base tables of `sim.js` as they are (those tables were retuned in the wave 4 balance pass, see `docs/BALANCE.md`). The room's difficulty is fixed for a game: the host picks
|
||||
it when creating the room (`join.difficulty`) or when starting a new game (`newgame.difficulty`).
|
||||
|
||||
## Tick loop
|
||||
|
||||
Fixed step `TD.STEP` (1/60 s) with an accumulator driven by `process.hrtime.bigint()`; real time elapsed is
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ opponent for either side so it can be played alone.
|
|||
| Base income | 4 credits/s, rising slowly (+0.02/s per second of the round) |
|
||||
| **Lifetime bonus** | every living attacker unit earns `cost x 0.004` credits per second alive, capped at 50% of its cost in total |
|
||||
| Leak bonus | a unit that reaches the server pays back its full cost (and damages integrity) |
|
||||
| Unit shop | every enemy kind has a `buyCost` in the sim's `ENEMIES` table (currently ping 10, worm 6, spam 3, ghost 15, trojan 30, daemon 25, proxy 30, botnet 3, rootkit 300; about 3x the kill reward, to be tuned by the versus balance pass) |
|
||||
| Unit shop | every enemy kind has a `buyCost` in the sim's `ENEMIES` table (currently ping 10, worm 6, spam 3, ghost 15, trojan 30, daemon 25, proxy 30, botnet 3, rootkit 180; about 3x the kill reward, to be tuned by the versus balance pass) |
|
||||
| Caps | at most 250 units alive, 200 staged (performance) |
|
||||
|
||||
**Save up and launch.** Units can be bought instantly (`spawn`) or **staged** (`stage`): the price is paid now, the units wait in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue