Fix population aggregation system to eliminate double-counting

- Fixed core issue where cells.pop and burg.population were both being counted
- Changed aggregation logic across all modules to use either burg OR cell population, never both
- If cell has burg: count only burg population (represents all people in that area)
- If cell has no burg: count only cells.pop (represents scattered population)

Files modified:
- modules/burgs-and-states.js: Fixed state population aggregation
- modules/ui/provinces-editor.js: Fixed province population aggregation
- modules/dynamic/editors/cultures-editor.js: Fixed culture population aggregation
- modules/dynamic/editors/religions-editor.js: Fixed religion population aggregation
- modules/ui/biomes-editor.js: Fixed biome population aggregation
- modules/ui/zones-editor.js: Fixed zone population calculations (2 locations)
- modules/military-generator.js: Redesigned military generation to use only burg populations

Military system changes:
- Removed rural military generation (all forces now come from settlements)
- Only burgs with 500+ people can maintain military forces
- Military strength based on actual burg population (2.5% mobilization rate)

Result: Population totals now consistent across all CSV exports (~2M total vs previous 40x discrepancy)
This commit is contained in:
barrulus 2025-08-13 18:54:32 +01:00
parent 334ef2b58b
commit e669549390
18 changed files with 2960 additions and 297 deletions

View file

@ -166,12 +166,40 @@ window.Cultures = (function () {
function defineCultureExpansionism(type) {
let base = 1; // Generic
if (type === "Lake") base = 0.8;
else if (type === "Naval") base = 1.5;
else if (type === "River") base = 0.9;
else if (type === "Nomadic") base = 1.5;
else if (type === "Hunting") base = 0.7;
else if (type === "Highland") base = 1.2;
let routeDensity = 1; // Route density modifier
let settlementPattern = "clustered"; // Settlement distribution pattern
// Define cultural characteristics that affect routes and settlements
if (type === "Lake") {
base = 0.8;
routeDensity = 0.9; // Moderate route density around lakes
settlementPattern = "lakeside";
} else if (type === "Naval") {
base = 1.5;
routeDensity = 1.3; // High route density for maritime trade
settlementPattern = "coastal";
} else if (type === "River") {
base = 0.9;
routeDensity = 1.2; // Dense routes along rivers
settlementPattern = "linear"; // Settlements follow river lines
} else if (type === "Nomadic") {
base = 1.5;
routeDensity = 0.5; // Few permanent routes
settlementPattern = "dispersed";
} else if (type === "Hunting") {
base = 0.7;
routeDensity = 0.6; // Minimal routes, mostly trails
settlementPattern = "scattered";
} else if (type === "Highland") {
base = 1.2;
routeDensity = 0.8; // Routes follow valleys
settlementPattern = "valley";
}
// Store additional cultural characteristics
cultures[cultures.length - 1].routeDensity = routeDensity;
cultures[cultures.length - 1].settlementPattern = settlementPattern;
return rn(((Math.random() * byId("sizeVariety").value) / 2 + 1) * base, 1);
}