Files
wownerogue/test/networkTuning_ultra.test.js
T
jwinterm f982f56181 fix(chain): WOW block time is 5 min, not 2 (measured); drop cheating-monster tuning
WOW meanBlockTimeMs 120000 -> 300000. Measured 5.01 min/block over 1000 blocks on
the live daemon; the code comment claiming it was "corrected to 2 min" was backwards.
WOW is a SLOW chain, closer to BTC than XMR for calibration.

Per user feedback ("fast monster feels like cheating") + what the sim then proved:
a supernaturally fast monster doesnt even WORK on slow chains — WOW (5-min) caps
~64% house-win even at a 2.2x monster on a 111x55 map, because a single dungeon
clears in ~1 min << the block so the timer (the fair, on-theme edge) barely bites.
So NETWORK_TUNING drops the monster-speed lever entirely and keeps size∝√blockTime
only (monster stays at its fair preset speed). WOW sizeScale 1.0->1.6 for 5-min blocks.

Consequence: slow chains (WOW/BTC) run honest-but-under-target on the timer until
MULTI-LEVEL DEPTH lands — the real edge lever (cumulative run length across levels
without any single map being an unplayable slog). Deb (WOW/normal) now gets a bigger,
more block-appropriate dungeon (45x22 -> 72x35) with a fair monster.

meanBlockTimeMs has no runtime consumer yet (metadata) so the WOW fix is behavior-safe
today; it corrects the sim + future block-bounded features. Suite 60/428 green.
2026-07-11 20:24:51 -04:00

66 lines
3.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Guards the per-network difficulty tuning: cryptoType must shape size (all presets) and monster
// (casino only), block-time ordering must hold, and operator env overrides must still win.
const {
DIFFICULTY_PRESETS, NETWORK_TUNING, applyNetworkTuning, getDifficultyConfig
} = require('../src/game/difficultyConfig');
const casino = () => ({ ...DIFFICULTY_PRESETS.casino, presetName: 'casino' });
const normal = () => ({ ...DIFFICULTY_PRESETS.normal, presetName: 'normal' });
// Isolate env mutations per test.
const SAVE = {};
const KEYS = ['NETWORK_TUNING_DISABLED', 'DUNGEON_WIDTH', 'MONSTER_SPEED', 'DIFFICULTY_PRESET', 'CRYPTO_TYPE', 'PAYMENTS_ENABLED', 'GAME_MODE'];
beforeEach(() => { KEYS.forEach(k => { SAVE[k] = process.env[k]; delete process.env[k]; }); });
afterEach(() => { KEYS.forEach(k => { if (SAVE[k] === undefined) delete process.env[k]; else process.env[k] = SAVE[k]; }); });
describe('per-network difficulty tuning', () => {
test('XMR is the reference (sizeScale 1.0) — casino dims unchanged; WOW (5-min) scales up', () => {
const xmr = applyNetworkTuning(casino(), 'XMR');
expect(xmr.dungeon.width).toBe(DIFFICULTY_PRESETS.casino.dungeon.width);
expect(xmr.dungeon.height).toBe(DIFFICULTY_PRESETS.casino.dungeon.height);
// WOW is a slow chain now (5 min) → bigger map than XMR.
expect(applyNetworkTuning(casino(), 'WOW').dungeon.width).toBeGreaterThan(xmr.dungeon.width);
});
test('dungeon size scales with block time: GRIN < XMR < WOW', () => {
const g = applyNetworkTuning(casino(), 'GRIN').dungeon.width;
const x = applyNetworkTuning(casino(), 'XMR').dungeon.width;
const w = applyNetworkTuning(casino(), 'WOW').dungeon.width;
expect(g).toBeLessThan(x);
expect(x).toBeLessThan(w);
});
test('tuning scales SIZE only — the monster stays at its fair preset speed', () => {
// No cheating-fast monster: every preset keeps its own movesPerPlayerMove.
expect(applyNetworkTuning(casino(), 'BTC').monster.movesPerPlayerMove)
.toBe(DIFFICULTY_PRESETS.casino.monster.movesPerPlayerMove);
expect(applyNetworkTuning(normal(), 'BTC').monster.movesPerPlayerMove)
.toBe(DIFFICULTY_PRESETS.normal.monster.movesPerPlayerMove);
// ...but both get the pacing size scale.
expect(applyNetworkTuning(normal(), 'BTC').dungeon.width).toBeGreaterThan(DIFFICULTY_PRESETS.normal.dungeon.width);
expect(NETWORK_TUNING.BTC.monsterSpeed).toBeUndefined();
});
test('unknown network is left untouched', () => {
const t = applyNetworkTuning(casino(), 'DOGE');
expect(t.dungeon.width).toBe(DIFFICULTY_PRESETS.casino.dungeon.width);
});
test('operator env overrides win over tuning', () => {
process.env.DIFFICULTY_PRESET = 'casino';
process.env.DUNGEON_WIDTH = '99';
process.env.MONSTER_SPEED = '1.0';
const cfg = getDifficultyConfig('BTC');
expect(cfg.dungeon.width).toBe(99); // env beats the 1.6× scale
expect(cfg.monster.movesPerPlayerMove).toBe(1.0); // env beats the 2.2 tuned speed
});
test('NETWORK_TUNING_DISABLED=true reverts to the raw preset', () => {
process.env.NETWORK_TUNING_DISABLED = 'true';
process.env.DIFFICULTY_PRESET = 'casino';
const cfg = getDifficultyConfig('BTC');
expect(cfg.dungeon.width).toBe(DIFFICULTY_PRESETS.casino.dungeon.width);
expect(cfg.monster.movesPerPlayerMove).toBe(DIFFICULTY_PRESETS.casino.monster.movesPerPlayerMove);
});
});