mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
Fix rural population calculation to only count small burgs
Rural population now correctly counted only from burgs with ≤100 people. Eliminates double-counting and ensures consistent statistics across charts and CSV exports.
This commit is contained in:
parent
e669549390
commit
8ec53293b7
2 changed files with 17 additions and 6 deletions
|
|
@ -1026,13 +1026,17 @@ window.BurgsAndStates = (() => {
|
||||||
states[s].cells += 1;
|
states[s].cells += 1;
|
||||||
states[s].area += cells.area[i];
|
states[s].area += cells.area[i];
|
||||||
if (cells.burg[i]) {
|
if (cells.burg[i]) {
|
||||||
// Burg represents ALL population for this cell (stored in thousands)
|
const burgPopulation = pack.burgs[cells.burg[i]].population;
|
||||||
states[s].urban += pack.burgs[cells.burg[i]].population;
|
if (burgPopulation > 0.1) {
|
||||||
|
// Large burg (>100 people) = urban population
|
||||||
|
states[s].urban += burgPopulation;
|
||||||
|
} else {
|
||||||
|
// Small burg (≤100 people) = rural population
|
||||||
|
states[s].rural += burgPopulation;
|
||||||
|
}
|
||||||
states[s].burgs++;
|
states[s].burgs++;
|
||||||
} else {
|
|
||||||
// Only count cells.pop for unsettled areas (no burg present)
|
|
||||||
states[s].rural += cells.pop[i];
|
|
||||||
}
|
}
|
||||||
|
// Cells without burgs have no population (rural population is housed in small burgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert neighbors Set object into array
|
// convert neighbors Set object into array
|
||||||
|
|
|
||||||
|
|
@ -672,7 +672,14 @@ function getUrbanPopulation(cellId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRuralPopulation(cellId) {
|
function getRuralPopulation(cellId) {
|
||||||
return pack.cells.pop[cellId] * populationRate;
|
const burgId = pack.cells.burg[cellId];
|
||||||
|
if (!burgId) return 0; // No burg = no rural population
|
||||||
|
|
||||||
|
const burgPopulation = pack.burgs[burgId].population;
|
||||||
|
if (burgPopulation > 0.1) return 0; // Burg has >100 people = no rural population
|
||||||
|
|
||||||
|
// Small burg (≤100 people) = count the burg's actual population as rural
|
||||||
|
return burgPopulation * 1000 * populationRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortData(data, sorting) {
|
function sortData(data, sorting) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue