First commit, done on M6 from the PLAN.MD

This commit is contained in:
gauvainboiche
2026-10-25 17:34:44 +01:00
parent d5dc2a3901
commit 04193e2013
86 changed files with 8396 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
// Sector quality drifts toward a target set by the budget ratio (alloc / need).
// Each sector has its own time constant: police reacts in weeks, infrastructure in years.
import { clamp, qualityFromRatio } from "./state.js";
import { biasFor } from "./modifiers.js";
export function stepSectors(state, bal, fiscal) {
const s = bal.sector;
for (const [id, sec] of Object.entries(state.sectors)) {
let target = qualityFromRatio(sec.alloc / sec.need, bal) + biasFor(state, "sector", id);
if (id === "industry" && fiscal.debtRatio > s.industryDebtPenaltyFrom) {
target -= s.industryDebtPenaltyPerPoint * (fiscal.debtRatio - s.industryDebtPenaltyFrom);
}
sec.quality = clamp(sec.quality + (clamp(target, 0, 100) - sec.quality) / bal.sectorTau[id], 0, 100);
}
}