diff --git a/index.html b/index.html
index ec30a12b..f0fa618a 100644
--- a/index.html
+++ b/index.html
@@ -3214,6 +3214,12 @@
+
+
diff --git a/main.js b/main.js
index a32b3aa0..539dea04 100644
--- a/main.js
+++ b/main.js
@@ -155,6 +155,7 @@ let options = {
let mapCoordinates = {}; // map coordinates on globe
let populationRate = +document.getElementById("populationRateInput").value;
let urbanization = +document.getElementById("urbanizationInput").value;
+let urbanDensity = +document.getElementById("urbanDensityInput").value;
applyStoredOptions();
diff --git a/modules/ui/burg-editor.js b/modules/ui/burg-editor.js
index c61b6ed9..2de633d5 100644
--- a/modules/ui/burg-editor.js
+++ b/modules/ui/burg-editor.js
@@ -408,7 +408,6 @@ function editBurg(id) {
document.getElementById("mfcgPreview").setAttribute("src", mfcgURL);
document.getElementById("mfcgLink").setAttribute("href", mfcgURL);
}
-
function getBurgSeed(burg) {
return burg.MFCG || Number(`${seed}${String(burg.i).padStart(4, 0)}`);
}
@@ -417,7 +416,7 @@ function editBurg(id) {
const {cells} = pack;
const {name, population, cell} = burg;
const burgSeed = getBurgSeed(burg);
- const size = minmax(rn(population), 6, 100);
+ const size = Math.max(Math.min(Math.ceil(2.13*Math.pow(population * populationRate/urbanDensity,0.385)), 100), 6);
const people = rn(population * populationRate * urbanization);
const hub = +cells.road[cell] > 50;
diff --git a/modules/ui/units-editor.js b/modules/ui/units-editor.js
index 54571191..be8f94c4 100644
--- a/modules/ui/units-editor.js
+++ b/modules/ui/units-editor.js
@@ -31,6 +31,8 @@ function editUnits() {
document.getElementById("populationRateInput").addEventListener("change", changePopulationRate);
document.getElementById("urbanizationOutput").addEventListener("input", changeUrbanizationRate);
document.getElementById("urbanizationInput").addEventListener("change", changeUrbanizationRate);
+ document.getElementById("urbanDensityOutput").addEventListener("input", changeUrbanDensity);
+ document.getElementById("urbanDensityInput").addEventListener("change", changeUrbanDensity);
document.getElementById("addLinearRuler").addEventListener("click", addRuler);
document.getElementById("addOpisometer").addEventListener("click", toggleOpisometerMode);
@@ -93,6 +95,10 @@ function editUnits() {
urbanization = +this.value;
}
+ function changeUrbanDensity() {
+ urbanDensity = +this.value;
+ }
+
function restoreDefaultUnits() {
// distanceScale
document.getElementById("distanceScaleOutput").value = 3;
@@ -135,8 +141,10 @@ function editUnits() {
// population
populationRate = populationRateOutput.value = populationRateInput.value = 1000;
urbanization = urbanizationOutput.value = urbanizationInput.value = 1;
+ urbanDensity = urbanDensityOutput.value = urbanDensityInput.value = 10;
localStorage.removeItem("populationRate");
localStorage.removeItem("urbanization");
+ localStorage.removeItem("urbanDensity")
}
function addRuler() {