Wrap up: review findings, balance baseline, bot tool and next-session notes

- docs/NEXT.md: where to pick up, prioritised, with the known wall-selling bug
  and its two-line fix
- docs/review-2026-10-09/: 85 reviewer findings (touch, co-op, client code,
  visual, reverse proxy) with verification status, repro scripts archive and
  the review workflow script; nothing fixed yet by design
- docs/BALANCE.md + tools/bot.js: headless balance bot and the untuned baseline
  (IDS Sniper dominates, maze is a near-guaranteed win, credits snowball)
- test/sim.test.js derives tunable numbers from the tables, plus a shape test
- README status note

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tb8pW2KAN4oFkh1aK1BfD8
This commit is contained in:
Claude 2026-10-09 21:38:59 +00:00
parent 45dea022ae
commit 72c49eee1f
8 changed files with 2187 additions and 9 deletions

View file

@ -38,8 +38,8 @@ test('placement validation: bounds, special cells, obstacles, occupancy, gold',
assert.equal(s.place({}, 5, 5).reason, 'bad_type');
assert.ok(s.place('wall', 5, 5).ok);
assert.equal(s.place('wall', 5, 5).reason, 'occupied');
assert.equal(s.gold, 95);
s.gold = 1;
assert.equal(s.gold, 100 - TOWERS.wall.levels[0].cost);
s.gold = TOWERS.wall.levels[0].cost - 1;
assert.equal(s.place('wall', 6, 5).reason, 'gold');
assert.equal(s.place('ids', 6, 5).reason, 'gold');
});
@ -110,7 +110,7 @@ test('monsters walk to the core and cost lives; flyers go straight', () => {
s.spawnQ.push({ t: 0, k: 'ghost', wave: 1 });
s.wave = 1;
run(s, 40);
assert.equal(s.lives, 18, 'ping 1 + ghost 1 leaked');
assert.equal(s.lives, 20 - ENEMIES.ping.leak - ENEMIES.ghost.leak, 'ping + ghost leaked');
assert.equal(s.monsters.length, 0);
});
@ -171,10 +171,12 @@ test('selling and upgrading', () => {
assert.ok(s.upgrade(t.id).ok);
assert.equal(s.upgrade(t.id).reason, 'max');
assert.equal(t.level, 3);
assert.equal(t.spent, 25 + 30 + 55);
const lv = TOWERS.filter.levels;
assert.equal(lv.length, 3);
assert.equal(t.spent, lv[0].cost + lv[1].cost + lv[2].cost);
const g = s.gold;
const sold = s.sell(t.id);
assert.equal(sold.refund, Math.floor(110 * TD.SELL_RATIO));
assert.equal(sold.refund, Math.floor(t.spent * TD.SELL_RATIO));
assert.equal(s.gold, g + sold.refund);
assert.equal(s.towers.length, 0);
assert.equal(s.sell(t.id).reason, 'no_tower');
@ -217,7 +219,7 @@ test('towers kill monsters and pay out; mortar cannot hit flyers', () => {
s2.spawnQ.push({ t: 0, k: 'ghost', wave: 1 });
run(s2, 20);
assert.equal(s2.kills, 0);
assert.equal(s2.lives, 19);
assert.equal(s2.lives, 20 - ENEMIES.ghost.leak);
});
test('throttle slows monsters; rootkit is partly resistant', () => {
@ -227,8 +229,10 @@ test('throttle slows monsters; rootkit is partly resistant', () => {
const a = mk('ping', 5.5, 7.5), b = mk('rootkit', 5.5, 7.5);
s.monsters = [a, b];
s.updateTower(s.towers[0], STEP);
assert.ok(Math.abs(a.slow - 0.35) < 1e-9);
assert.ok(Math.abs(b.slow - 0.175) < 1e-9);
const slow1 = TOWERS.throttle.levels[0].slow;
assert.ok(Math.abs(a.slow - slow1) < 1e-9);
assert.ok(Math.abs(b.slow - slow1 * (1 - ENEMIES.rootkit.slowRes)) < 1e-9);
assert.ok(b.slow < a.slow);
});
test('waves: queue, clear bonus, win and lose states, auto waves', () => {
@ -237,7 +241,9 @@ test('waves: queue, clear bonus, win and lose states, auto waves', () => {
assert.ok(s.spawnQ.length > 0);
run(s, 60);
assert.equal(s.state, 'won');
assert.equal(s.gold, 12, 'wave clear bonus 10 + 2*wave');
const clear = s.drainEvents().find((e) => e.e === 'clear');
assert.ok(clear && clear.bonus > 0 && clear.n === 1, 'a clear event with a positive bonus');
assert.equal(s.gold, clear.bonus, 'the wave clear bonus is the only income of an undefended wave');
assert.ok(s.continueEndless().ok);
assert.equal(s.state, 'playing');
assert.ok(s.startWave().ok);
@ -305,3 +311,39 @@ test('fuzz: garbage commands never throw', () => {
for (const j of junk) assert.doesNotThrow(() => s.cmd(j));
assert.equal(s.towers.length, 0);
});
test('balance tables keep the shape the client and server rely on', () => {
assert.deepEqual(TD.TOWER_ORDER, ['wall', 'filter', 'ids', 'mortar', 'throttle', 'arc']);
assert.deepEqual(TD.ENEMY_ORDER, ['ping', 'worm', 'trojan', 'spam', 'ghost', 'rootkit']);
assert.equal(TOWERS.wall.levels.length, 1);
assert.ok(TOWERS.wall.refund, 'walls refund in full');
for (const k of TD.TOWER_ORDER) {
const t = TOWERS[k];
assert.ok(t.name && t.color && t.key && t.desc, k + ' has display fields');
if (k === 'wall') continue;
assert.equal(t.levels.length, 3, k + ' has exactly 3 levels');
t.levels.forEach((lv, i) => {
assert.ok(lv.cost > 0 && lv.range > 0, k + ' L' + (i + 1) + ' cost/range');
if (k === 'throttle') assert.ok(lv.slow > 0 && lv.slow <= 0.6, 'slow is capped at 0.6 by the sim');
else assert.ok(lv.dmg > 0 && lv.rate > 0, k + ' L' + (i + 1) + ' dmg/rate');
if (k === 'mortar') assert.ok(lv.splash > 0);
if (k === 'arc') assert.ok(lv.chains >= 1 && lv.chainRange > 0 && lv.falloff > 0 && lv.falloff < 1);
if (i > 0) assert.ok(lv.range >= t.levels[i - 1].range, 'range never shrinks on upgrade');
});
}
for (const k of TD.ENEMY_ORDER) {
const e = ENEMIES[k];
assert.ok(e.name && e.color && e.hp > 0 && e.speed > 0 && e.reward > 0 && e.leak > 0 && e.armor >= 0 && e.r > 0, k);
}
assert.ok(TD.START_GOLD >= TOWERS.filter.levels[0].cost * 2, 'the opening credits buy at least two turrets');
assert.ok(TD.SELL_RATIO > 0 && TD.SELL_RATIO < 1, 'selling a turret always loses credits');
// no way to turn credits into more credits by buying, upgrading and selling
for (const k of TD.TOWER_ORDER) {
if (k === 'wall') continue;
const spent = TOWERS[k].levels.reduce((a, l) => a + l.cost, 0);
assert.ok(Math.floor(spent * TD.SELL_RATIO) < spent);
}
// the opening waves are survivable with the opening credits and wave pressure never decreases
for (let n = 2; n <= 60; n++) assert.ok(TD.hpScale(n) > TD.hpScale(n - 1));
for (let n = 2; n <= 60; n++) assert.ok(TD.rewardScale(n) >= TD.rewardScale(n - 1));
});