mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 02:01:22 +01:00
Merge branch 'master' of https://github.com/Azgaar/Fantasy-Map-Generator into burg-groups
This commit is contained in:
commit
e402120b8d
42 changed files with 1526 additions and 1067 deletions
|
|
@ -50,7 +50,8 @@ window.States = (() => {
|
|||
const {cells, states, cultures, burgs} = pack;
|
||||
|
||||
cells.state = cells.state || new Uint16Array(cells.i.length);
|
||||
const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
|
||||
|
||||
const queue = new FlatQueue();
|
||||
const cost = [];
|
||||
|
||||
const globalGrowthRate = byId("growthRate").valueAsNumber || 1;
|
||||
|
|
@ -71,12 +72,13 @@ window.States = (() => {
|
|||
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});
|
||||
queue.push({e: state.center, p: 0, s: state.i, b}, 0);
|
||||
cost[state.center] = 1;
|
||||
}
|
||||
|
||||
while (queue.length) {
|
||||
const next = queue.dequeue();
|
||||
const next = queue.pop();
|
||||
|
||||
const {e, p, s, b} = next;
|
||||
const {type, culture} = states[s];
|
||||
|
||||
|
|
@ -99,7 +101,7 @@ window.States = (() => {
|
|||
if (!cost[e] || totalCost < cost[e]) {
|
||||
if (cells.h[e] >= 20) cells.state[e] = s; // assign state to cell
|
||||
cost[e] = totalCost;
|
||||
queue.queue({e, p: totalCost, s, b});
|
||||
queue.push({e, p: totalCost, s, b}, totalCost);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue