mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 03:51:23 +01:00
Merge branch 'master' into faith-update
This commit is contained in:
commit
fc1b99762e
9 changed files with 70 additions and 44 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
To get heightmap with correct height scale:
|
To get heightmap with correct height scale:
|
||||||
1. Open tangrams.github.io
|
1. Open https://tangrams.github.io/heightmapper
|
||||||
2. Toggle off auto-exposure
|
2. Toggle off auto-exposure
|
||||||
3. Set max elevation to 2000
|
3. Set max elevation to 2000
|
||||||
4. Set min elevation to -500
|
4. Set min elevation to -500
|
||||||
5. Find region you like
|
5. Find region you like
|
||||||
6. Render image
|
6. Render image
|
||||||
7. Optionally rescale image to a smaller size (e.g. 500x300px) as high resolution is not used
|
7. Optionally rescale image to a smaller size (e.g. 500x300px) as high resolution is not used
|
||||||
|
|
|
||||||
|
|
@ -7863,14 +7863,14 @@
|
||||||
|
|
||||||
<script src="modules/ui/general.js?v=1.87.03"></script>
|
<script src="modules/ui/general.js?v=1.87.03"></script>
|
||||||
<script src="modules/ui/options.js?v=1.88.02"></script>
|
<script src="modules/ui/options.js?v=1.88.02"></script>
|
||||||
<script src="main.js?v=1.88.02"></script>
|
<script src="main.js?v=1.89.05"></script>
|
||||||
|
|
||||||
<script defer src="modules/relief-icons.js"></script>
|
<script defer src="modules/relief-icons.js"></script>
|
||||||
<script defer src="modules/ui/style.js"></script>
|
<script defer src="modules/ui/style.js"></script>
|
||||||
<script defer src="modules/ui/editors.js?v=1.90.00"></script>
|
<script defer src="modules/ui/editors.js?v=1.90.00"></script>
|
||||||
<script defer src="modules/ui/tools.js?v=1.89.00"></script>
|
<script defer src="modules/ui/tools.js?v=1.89.00"></script>
|
||||||
<script defer src="modules/ui/world-configurator.js"></script>
|
<script defer src="modules/ui/world-configurator.js"></script>
|
||||||
<script defer src="modules/ui/heightmap-editor.js?v=1.88.03"></script>
|
<script defer src="modules/ui/heightmap-editor.js?v=1.89.06"></script>
|
||||||
<script defer src="modules/ui/provinces-editor.js?v=1.89.00"></script>
|
<script defer src="modules/ui/provinces-editor.js?v=1.89.00"></script>
|
||||||
<script defer src="modules/ui/biomes-editor.js"></script>
|
<script defer src="modules/ui/biomes-editor.js"></script>
|
||||||
<script defer src="modules/ui/namesbase-editor.js?v=1.87.10"></script>
|
<script defer src="modules/ui/namesbase-editor.js?v=1.87.10"></script>
|
||||||
|
|
|
||||||
1
main.js
1
main.js
|
|
@ -191,7 +191,6 @@ let populationRate = +document.getElementById("populationRateInput").value;
|
||||||
let distanceScale = +document.getElementById("distanceScaleInput").value;
|
let distanceScale = +document.getElementById("distanceScaleInput").value;
|
||||||
let urbanization = +document.getElementById("urbanizationInput").value;
|
let urbanization = +document.getElementById("urbanizationInput").value;
|
||||||
let urbanDensity = +document.getElementById("urbanDensityInput").value;
|
let urbanDensity = +document.getElementById("urbanDensityInput").value;
|
||||||
let statesNeutral = 1; // statesEditor growth parameter
|
|
||||||
|
|
||||||
applyStoredOptions();
|
applyStoredOptions();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -359,7 +359,7 @@ window.BurgsAndStates = (function () {
|
||||||
TIME && console.timeEnd("drawBurgs");
|
TIME && console.timeEnd("drawBurgs");
|
||||||
};
|
};
|
||||||
|
|
||||||
// growth algorithm to assign cells to states like we did for cultures
|
// expand cultures across the map (Dijkstra-like algorithm)
|
||||||
const expandStates = function () {
|
const expandStates = function () {
|
||||||
TIME && console.time("expandStates");
|
TIME && console.time("expandStates");
|
||||||
const {cells, states, cultures, burgs} = pack;
|
const {cells, states, cultures, burgs} = pack;
|
||||||
|
|
@ -367,18 +367,28 @@ window.BurgsAndStates = (function () {
|
||||||
cells.state = cells.state || new Uint16Array(cells.i.length);
|
cells.state = cells.state || new Uint16Array(cells.i.length);
|
||||||
const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
|
const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
|
||||||
const cost = [];
|
const cost = [];
|
||||||
const neutral = (cells.i.length / 5000) * 2500 * neutralInput.value * statesNeutral; // limit cost for state growth
|
|
||||||
|
|
||||||
states
|
const globalNeutralRate = byId("neutralInput")?.valueAsNumber || 1;
|
||||||
.filter(s => s.i && !s.removed)
|
const statesNeutralRate = byId("statesNeutral")?.valueAsNumber || 1;
|
||||||
.forEach(s => {
|
const neutral = (cells.i.length / 2) * globalNeutralRate * statesNeutralRate; // limit cost for state growth
|
||||||
const capitalCell = burgs[s.capital].cell;
|
|
||||||
cells.state[capitalCell] = s.i;
|
// remove state from all cells except of locked
|
||||||
const cultureCenter = cultures[s.culture].center;
|
for (const cellId of cells.i) {
|
||||||
const b = cells.biome[cultureCenter]; // state native biome
|
const state = states[cells.state[cellId]];
|
||||||
queue.queue({e: s.center, p: 0, s: s.i, b});
|
if (state.lock) continue;
|
||||||
cost[s.center] = 1;
|
cells.state[cellId] = 0;
|
||||||
});
|
}
|
||||||
|
|
||||||
|
for (const state of states) {
|
||||||
|
if (!state.i || state.removed) continue;
|
||||||
|
|
||||||
|
const capitalCell = burgs[state.capital].cell;
|
||||||
|
cells.state[capitalCell] = state.i;
|
||||||
|
const cultureCenter = cultures[state.culture].center;
|
||||||
|
const b = cells.biome[cultureCenter]; // state native biome
|
||||||
|
queue.queue({e: state.center, p: 0, s: state.i, b});
|
||||||
|
cost[state.center] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
while (queue.length) {
|
while (queue.length) {
|
||||||
const next = queue.dequeue();
|
const next = queue.dequeue();
|
||||||
|
|
|
||||||
|
|
@ -116,10 +116,10 @@ window.Cultures = (function () {
|
||||||
|
|
||||||
cultures.forEach(c => (c.base = c.base % nameBases.length));
|
cultures.forEach(c => (c.base = c.base % nameBases.length));
|
||||||
|
|
||||||
function selectCultures(c) {
|
function selectCultures(culturesNumber) {
|
||||||
let def = getDefault(c);
|
let def = getDefault(culturesNumber);
|
||||||
const cultures = [];
|
const cultures = [];
|
||||||
|
|
||||||
pack.cultures?.forEach(function (culture) {
|
pack.cultures?.forEach(function (culture) {
|
||||||
if (culture.lock) cultures.push(culture);
|
if (culture.lock) cultures.push(culture);
|
||||||
});
|
});
|
||||||
|
|
@ -153,8 +153,8 @@ window.Cultures = (function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (c === def.length) return def;
|
if (culturesNumber === def.length) return def;
|
||||||
if (def.every(d => d.odd === 1)) return def.splice(0, c);
|
if (def.every(d => d.odd === 1)) return def.splice(0, culturesNumber);
|
||||||
if (pack.religions?.length > 2) {
|
if (pack.religions?.length > 2) {
|
||||||
pack.religions.forEach(r => {
|
pack.religions.forEach(r => {
|
||||||
if (r.type === "Folk" && !r.lock) r.removed = true;
|
if (r.type === "Folk" && !r.lock) r.removed = true;
|
||||||
|
|
@ -162,7 +162,7 @@ window.Cultures = (function () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let culture, rnd, i = 0; cultures.length < c && def.length > 0;) {
|
for (let culture, rnd, i = 0; cultures.length < culturesNumber && def.length > 0;) {
|
||||||
do {
|
do {
|
||||||
rnd = rand(def.length - 1);
|
rnd = rand(def.length - 1);
|
||||||
culture = def[rnd];
|
culture = def[rnd];
|
||||||
|
|
@ -542,28 +542,37 @@ window.Cultures = (function () {
|
||||||
// expand cultures across the map (Dijkstra-like algorithm)
|
// expand cultures across the map (Dijkstra-like algorithm)
|
||||||
const expand = function () {
|
const expand = function () {
|
||||||
TIME && console.time("expandCultures");
|
TIME && console.time("expandCultures");
|
||||||
cells = pack.cells;
|
const {cells, cultures} = pack;
|
||||||
|
|
||||||
const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
|
const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
|
||||||
pack.cultures.forEach(function (c) {
|
|
||||||
if (!c.i || c.removed || c.lock) return;
|
|
||||||
queue.queue({e: c.center, p: 0, c: c.i});
|
|
||||||
});
|
|
||||||
|
|
||||||
const neutral = (cells.i.length / 5000) * 3000 * neutralInput.value; // limit cost for culture growth
|
|
||||||
const cost = [];
|
const cost = [];
|
||||||
|
|
||||||
|
const neutralRate = byId("neutralRate")?.valueAsNumber || 1;
|
||||||
|
const neutral = cells.i.length * 0.6 * neutralRate; // limit cost for culture growth
|
||||||
|
|
||||||
|
// remove culture from all cells except of locked
|
||||||
|
for (const cellId of cells.i) {
|
||||||
|
const culture = cultures[cells.culture[cellId]];
|
||||||
|
if (culture.lock) continue;
|
||||||
|
cells.culture[cellId] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const culture of cultures) {
|
||||||
|
if (!culture.i || culture.removed) continue;
|
||||||
|
queue.queue({e: culture.center, p: 0, c: culture.i});
|
||||||
|
}
|
||||||
|
|
||||||
while (queue.length) {
|
while (queue.length) {
|
||||||
const next = queue.dequeue(),
|
const {e, p, c} = queue.dequeue();
|
||||||
n = next.e,
|
const {type} = pack.cultures[c];
|
||||||
p = next.p,
|
|
||||||
c = next.c;
|
cells.c[e].forEach(e => {
|
||||||
const type = pack.cultures[c].type;
|
const culture = cells.culture[e];
|
||||||
cells.c[n].forEach(e => {
|
if (culture?.lock) return; // do not overwrite cell of locked culture
|
||||||
if (pack.cultures[cells.culture[e]]?.lock) return;
|
|
||||||
|
|
||||||
const biome = cells.biome[e];
|
const biome = cells.biome[e];
|
||||||
const biomeCost = getBiomeCost(c, biome, type);
|
const biomeCost = getBiomeCost(c, biome, type);
|
||||||
const biomeChangeCost = biome === cells.biome[n] ? 0 : 20; // penalty on biome change
|
const biomeChangeCost = biome === cells.biome[e] ? 0 : 20; // penalty on biome change
|
||||||
const heightCost = getHeightCost(e, cells.h[e], type);
|
const heightCost = getHeightCost(e, cells.h[e], type);
|
||||||
const riverCost = getRiverCost(cells.r[e], e, type);
|
const riverCost = getRiverCost(cells.r[e], e, type);
|
||||||
const typeCost = getTypeCost(cells.t[e], type);
|
const typeCost = getTypeCost(cells.t[e], type);
|
||||||
|
|
|
||||||
|
|
@ -883,7 +883,6 @@ function changeStatesGrowthRate() {
|
||||||
const growthRate = +this.value;
|
const growthRate = +this.value;
|
||||||
byId("statesNeutral").value = growthRate;
|
byId("statesNeutral").value = growthRate;
|
||||||
byId("statesNeutralNumber").value = growthRate;
|
byId("statesNeutralNumber").value = growthRate;
|
||||||
statesNeutral = growthRate;
|
|
||||||
tip("Growth rate: " + growthRate);
|
tip("Growth rate: " + growthRate);
|
||||||
recalculateStates(false);
|
recalculateStates(false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -351,9 +351,8 @@ window.Religions = (function () {
|
||||||
const codes = [];
|
const codes = [];
|
||||||
|
|
||||||
// add folk religions
|
// add folk religions
|
||||||
pack.cultures.forEach(c => {
|
cultures.forEach(c => {
|
||||||
const newId = c.i;
|
if (!c.i) return religions.push({i: 0, name: "No religion"});
|
||||||
if (!newId) return religions.push({i: 0, name: "No religion"});
|
|
||||||
|
|
||||||
if (c.removed) {
|
if (c.removed) {
|
||||||
religions.push({
|
religions.push({
|
||||||
|
|
@ -365,6 +364,8 @@ window.Religions = (function () {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const newId = c.i;
|
||||||
|
|
||||||
if (pack.religions) {
|
if (pack.religions) {
|
||||||
const lockedFolkReligion = pack.religions.find(
|
const lockedFolkReligion = pack.religions.find(
|
||||||
r => r.culture === c.i && !r.removed && r.lock && r.type === "Folk"
|
r => r.culture === c.i && !r.removed && r.lock && r.type === "Folk"
|
||||||
|
|
@ -868,7 +869,6 @@ window.Religions = (function () {
|
||||||
r.culture = cells.culture[r.center];
|
r.culture = cells.culture[r.center];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
TIME && console.timeEnd("updateCulturesForReligions");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get supreme deity name
|
// get supreme deity name
|
||||||
|
|
|
||||||
|
|
@ -1176,7 +1176,7 @@ function refreshAllEditors() {
|
||||||
// dynamically loaded editors
|
// dynamically loaded editors
|
||||||
async function editStates() {
|
async function editStates() {
|
||||||
if (customization) return;
|
if (customization) return;
|
||||||
const Editor = await import("../dynamic/editors/states-editor.js?v=1.89.02");
|
const Editor = await import("../dynamic/editors/states-editor.js?v=1.89.05");
|
||||||
Editor.open();
|
Editor.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -204,6 +204,13 @@ function editHeightmap(options) {
|
||||||
INFO && console.group("Edit Heightmap");
|
INFO && console.group("Edit Heightmap");
|
||||||
TIME && console.time("regenerateErasedData");
|
TIME && console.time("regenerateErasedData");
|
||||||
|
|
||||||
|
// remove data
|
||||||
|
pack.cultures = [];
|
||||||
|
pack.burgs = [];
|
||||||
|
pack.states = [];
|
||||||
|
pack.provinces = [];
|
||||||
|
pack.religions = [];
|
||||||
|
|
||||||
const erosionAllowed = allowErosion.checked;
|
const erosionAllowed = allowErosion.checked;
|
||||||
markFeatures();
|
markFeatures();
|
||||||
markupGridOcean();
|
markupGridOcean();
|
||||||
|
|
@ -231,8 +238,10 @@ function editHeightmap(options) {
|
||||||
Lakes.defineGroup();
|
Lakes.defineGroup();
|
||||||
defineBiomes();
|
defineBiomes();
|
||||||
rankCells();
|
rankCells();
|
||||||
|
|
||||||
Cultures.generate();
|
Cultures.generate();
|
||||||
Cultures.expand();
|
Cultures.expand();
|
||||||
|
|
||||||
BurgsAndStates.generate();
|
BurgsAndStates.generate();
|
||||||
Religions.generate();
|
Religions.generate();
|
||||||
BurgsAndStates.defineStateForms();
|
BurgsAndStates.defineStateForms();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue