mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 09:41:24 +01:00
fix: state expansion to reset on re-generation
This commit is contained in:
parent
7d500b1598
commit
eb5d924cbd
6 changed files with 26 additions and 18 deletions
|
|
@ -367,18 +367,28 @@ window.BurgsAndStates = (function () {
|
|||
cells.state = cells.state || new Uint16Array(cells.i.length);
|
||||
const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
|
||||
const cost = [];
|
||||
const neutral = (cells.i.length / 5000) * 2500 * neutralInput.value * statesNeutral; // limit cost for state growth
|
||||
|
||||
states
|
||||
.filter(s => s.i && !s.removed)
|
||||
.forEach(s => {
|
||||
const capitalCell = burgs[s.capital].cell;
|
||||
cells.state[capitalCell] = s.i;
|
||||
const cultureCenter = cultures[s.culture].center;
|
||||
const b = cells.biome[cultureCenter]; // state native biome
|
||||
queue.queue({e: s.center, p: 0, s: s.i, b});
|
||||
cost[s.center] = 1;
|
||||
});
|
||||
const globalNeutralRate = byId("neutralInput")?.value || 1;
|
||||
const statesNeutralRate = byId("statesNeutral")?.value || 1;
|
||||
const neutral = (cells.i.length / 2) * globalNeutralRate * statesNeutralRate; // limit cost for state growth
|
||||
|
||||
// remove state from all cells except of locked
|
||||
for (const cellId of cells.i) {
|
||||
const state = states[cells.state[cellId]];
|
||||
if (state.lock) continue;
|
||||
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) {
|
||||
const next = queue.dequeue();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue