// The world outside the country: a slow business cycle with occasional shocks (global // slumps, rare booms). It moves growth and inflation, so even a perfect budget meets // good and bad years. state.world.cycle is roughly -4 (deep global recession) to +4. import { clamp } from "./state.js"; import { nextFloat, nextNoise } from "./rng.js"; export function stepWorld(state, bal) { const w = bal.world; const s = state.world; s.cycle -= s.cycle / w.tau; s.cycle += nextNoise(state, w.noise); if (nextFloat(state) < w.shockChancePerDay) { const size = w.shock * (0.6 + 0.8 * nextFloat(state)); s.cycle += nextFloat(state) < w.boomShare ? size * 0.6 : -size; } s.cycle = clamp(s.cycle, -w.max, w.max); }