Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Draft] Economics v2 #1182

Open
wants to merge 67 commits into
base: dev-economics-2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
cb486fa
reinstate economics logic
sofronaspe Sep 26, 2024
877e269
added names to the random names of zones (#1128)
Avengium Sep 11, 2024
9f3e707
hotfix: 1.103.7
Sep 12, 2024
1e0b4d6
fix: #1129
Sep 12, 2024
6990117
Refactor layers rendering (#1120)
Azgaar Sep 20, 2024
e671739
style: reduce submap dialog width - v1.104.1
Sep 20, 2024
a385db1
feat: use StaleWhileRevalidate for scripts poloicy; v1.104.2
Sep 20, 2024
19ee111
fix: routes (v1.104.3)
Sep 20, 2024
0a38834
fix: service worker fn
Sep 20, 2024
bc08cd8
fix: #1136
Sep 20, 2024
373d6fa
fix: slow load
Sep 20, 2024
49bfd20
fix: heightmap edit in Erase mode
Sep 20, 2024
7b526cc
fix: layers - show emblems on render
Sep 21, 2024
4c2f878
fix: heightmap edit in Risk mode
Sep 21, 2024
28a69b9
fix: remove route if it has <2 points
Sep 21, 2024
f5bb89c
fix: loose format requirements for old files to show correct message
Sep 21, 2024
e9cfa64
fix: don't hide armies layer
Sep 21, 2024
306eb94
fix: draw military fn reference
Sep 21, 2024
be4f206
fix: split regiment v1.104.14
Sep 22, 2024
7f8fab9
fix: features - define first cell
Sep 22, 2024
1ffcea2
AI Assistant widget (#1115)
Azgaar Sep 22, 2024
342ee80
feat: battles - move Regiments back to init position after the battle
Sep 22, 2024
10a7e45
fix: disable double-click on heightmap edit
Sep 22, 2024
bfb1c51
chore: supporters update
Sep 23, 2024
3810313
chore: set libs version
Sep 23, 2024
c8885c0
fix: typo
Sep 25, 2024
167e880
fix: redraw features on load
Sep 25, 2024
e99394c
fix: issue with feature vertex being out of bound
Sep 25, 2024
8ed24c2
refactor: burg types
Sep 27, 2024
6af79e1
fix: gap path to not omit the M path sign
Sep 29, 2024
9da6f22
feat: allow to crean data in case of load error
Oct 1, 2024
c7f38f7
fix: remove unwanted states styling
Oct 3, 2024
e1d70da
fix: allow to load smaller namesbase without issues on regeneration
Oct 8, 2024
d05237e
fix #1152
Oct 11, 2024
3f50a31
fix: #1152, don't keep removed locked cultures on regenerate
Oct 13, 2024
15eef02
fix: #1152, don't keep removed locked cultures on regenerate
Oct 13, 2024
6c39a67
fix: features rendering - close the ring
Oct 13, 2024
bb6bd72
fix: lock all burgs
Oct 16, 2024
53a6892
Draw state labels improvement (#1155)
Azgaar Oct 19, 2024
ed92b5e
fix: CRLF issue
Oct 19, 2024
bf1a407
fix: zones editor - legend to be toggable
Oct 19, 2024
1e00161
chore: parse DEBUG setting as an object
Oct 22, 2024
012f19a
chore: update 1.105.19 hash
Oct 22, 2024
ef2eb0a
feat: zones editor - don't close other editors on open
Oct 22, 2024
8f583e9
Removed priority queue in favor of FlatQueue (#1157)
RyanGuild Oct 26, 2024
b2e5c04
fix: add p to priority queue
Oct 26, 2024
7a75c57
Stroke dash to cells (#1159)
Avengium Oct 26, 2024
f123f7b
Temperature parameters can be customized (#1162)
dyxang Nov 7, 2024
6263998
AI Claude support (#1167)
Azgaar Nov 14, 2024
281abf4
chore: supporters update
Nov 15, 2024
31c1303
fix: #1170
Nov 24, 2024
56df31d
fix: #1172
Nov 27, 2024
a6f0b8b
chore: update supporters
Nov 28, 2024
27e43eb
Update FUNDING.yml
Azgaar Nov 28, 2024
8a4b83f
[Draft] Submap refactoring (#1153)
Azgaar Dec 12, 2024
1cbcdbe
fix: #1174
Dec 13, 2024
0c15957
fix: submap - generate in current canvas size
Dec 13, 2024
73c71d5
fix: don't mask routes
Dec 13, 2024
2d7a816
fix: sumap - clip routes by bbox
Dec 14, 2024
1898a1c
style: increase dialog buttons size
Dec 16, 2024
c6377a5
feat: like temp likeness, 1.106.6
Dec 17, 2024
308ead9
fix: 1.106.7 - rivers starting width calc
Dec 17, 2024
b421191
reinstate economics logic
sofronaspe Sep 26, 2024
063c440
adjust to align with master
sofronaspe Jan 11, 2025
efbca32
Rebase, add functionality to Resources editor.
sofronaspe Jan 11, 2025
9ce260a
Fix icon size in burg editor.
sofronaspe Jan 11, 2025
80bbf5b
Merge branch 'dev-economics-2' into economics-v2
sofronaspe Jan 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Removed priority queue in favor of FlatQueue (#1157)
* removed priority queue in favor of simple array extension as it will be easier to migrate to esm

* patch: bump version

* spacing

* moved references to globalThis

* demonstrate module interop

* added version to priority-queue and moved to utils to follow dom loading pattern

* removed PriorityQueue in favor of FlatQueue

* update index.html

* never mind that force push I don't know how to amend commits right

* missing capitalization

* priority set to 0 on 541

---------

Co-authored-by: RyanGuild <[email protected]>
  • Loading branch information
2 people authored and sofronaspe committed Jan 11, 2025
commit 8f583e9a808b97b2f8950ab9ddb045ad4dab4f09
10 changes: 5 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8326,7 +8326,6 @@
<script src="libs/jquery-ui.min.js"></script>
<script src="versioning.js"></script>
<script src="libs/d3.min.js"></script>
<script src="libs/priority-queue.min.js"></script>
<script src="libs/flatqueue.js"></script>
<script src="libs/delaunator.min.js"></script>
<script src="libs/indexedDB.js?v=1.99.00"></script>
Expand Down Expand Up @@ -8357,17 +8356,18 @@
<script src="modules/lakes.js?v=1.99.00"></script>
<script src="modules/biomes.js?v=1.99.00"></script>
<script src="modules/names-generator.js?v=1.105.11"></script>
<script src="modules/cultures-generator.js?v=1.105.13"></script>
<script src="modules/resources-generator.js"></script>
<script src="modules/renderers/state-labels.js?v=1.96.04"></script>
<script src="modules/burgs-and-states.js?v=1.99.06"></script>
<script src="modules/production-generator.js"></script>
<script src="modules/trade-generator.js"></script>
<script src="modules/cultures-generator.js?v=1.105.21"></script>
<script src="modules/burgs-and-states.js?v=1.105.21"></script>
<script src="modules/provinces-generator.js?v=1.105.21"></script>
<script src="modules/routes-generator.js?v=1.104.10"></script>
<script src="modules/religions-generator.js?v=1.99.05"></script>
<script src="modules/religions-generator.js?v=1.105.21"></script>
<script src="modules/military-generator.js?v=1.104.0"></script>
<script src="modules/markers-generator.js?v=1.104.0"></script>
<script src="modules/zones-generator.js?v=1.104.0"></script>
<script src="modules/zones-generator.js?v=1.105.21"></script>
<script src="modules/coa-generator.js?v=1.99.00"></script>
<script src="modules/ui/resources-editor.js"></script>
<script src="modules/submap.js?v=1.104.0"></script>
Expand Down
1 change: 0 additions & 1 deletion libs/priority-queue.min.js

This file was deleted.

10 changes: 6 additions & 4 deletions modules/burgs-and-states.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ window.BurgsAndStates = (() => {
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;
Expand All @@ -307,12 +308,13 @@ window.BurgsAndStates = (() => {
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];

Expand All @@ -335,7 +337,7 @@ window.BurgsAndStates = (() => {
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);
}
});
}
Expand Down
8 changes: 4 additions & 4 deletions modules/cultures-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ window.Cultures = (function () {
TIME && console.time("expandCultures");
const {cells, cultures} = pack;

const queue = new PriorityQueue({comparator: (a, b) => a.priority - b.priority});
const queue = new FlatQueue();
const cost = [];

const neutralRate = byId("neutralRate")?.valueAsNumber || 1;
Expand All @@ -538,11 +538,11 @@ window.Cultures = (function () {

for (const culture of cultures) {
if (!culture.i || culture.removed || culture.lock) continue;
queue.queue({cellId: culture.center, cultureId: culture.i, priority: 0});
queue.push({cellId: culture.center, cultureId: culture.i, priority: 0}, 0);
}

while (queue.length) {
const {cellId, priority, cultureId} = queue.dequeue();
const {cellId, priority, cultureId} = queue.pop();
const {type, expansionism} = cultures[cultureId];

cells.c[cellId].forEach(neibCellId => {
Expand All @@ -566,7 +566,7 @@ window.Cultures = (function () {
if (!cost[neibCellId] || totalCost < cost[neibCellId]) {
if (cells.pop[neibCellId] > 0) cells.culture[neibCellId] = cultureId; // assign culture to populated cell
cost[neibCellId] = totalCost;
queue.queue({cellId: neibCellId, cultureId, priority: totalCost});
queue.push({cellId: neibCellId, cultureId, priority: totalCost}, totalCost);
}
});
}
Expand Down
22 changes: 11 additions & 11 deletions modules/provinces-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,18 @@ window.Provinces = (function () {
});

// expand generated provinces
const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
const queue = new FlatQueue();
const cost = [];

provinces.forEach(p => {
if (!p.i || p.removed || isProvinceLocked(p)) return;
provinceIds[p.center] = p.i;
queue.queue({e: p.center, p: 0, province: p.i, state: p.state});
queue.push({e: p.center, province: p.i, state: p.state, p: 0}, 0);
cost[p.center] = 1;
});

while (queue.length) {
const {e, p, province, state} = queue.dequeue();
const {e, p, province, state} = queue.pop();

cells.c[e].forEach(e => {
if (isProvinceCellLocked(e)) return; // do not overwrite cell of locked provinces
Expand All @@ -103,7 +103,7 @@ window.Provinces = (function () {
if (!cost[e] || totalCost < cost[e]) {
if (land) provinceIds[e] = province; // assign province to a cell
cost[e] = totalCost;
queue.queue({e, p: totalCost, province, state});
queue.push({e, province, state, p: totalCost}, totalCost);
}
});
}
Expand Down Expand Up @@ -158,9 +158,9 @@ window.Provinces = (function () {
// expand province
const cost = [];
cost[center] = 1;
queue.queue({e: center, p: 0});
queue.push({e: center, p: 0}, 0);
while (queue.length) {
const {e, p} = queue.dequeue();
const {e, p} = queue.pop();

cells.c[e].forEach(nextCellId => {
if (provinceIds[nextCellId]) return;
Expand All @@ -173,7 +173,7 @@ window.Provinces = (function () {
if (!cost[nextCellId] || totalCost < cost[nextCellId]) {
if (land && cells.state[nextCellId] === s.i) provinceIds[nextCellId] = provinceId; // assign province to a cell
cost[nextCellId] = totalCost;
queue.queue({e: nextCellId, p: totalCost});
queue.push({e: nextCellId, p: totalCost}, totalCost);
}
});
}
Expand Down Expand Up @@ -216,15 +216,15 @@ window.Provinces = (function () {
// check if there is a land way within the same state between two cells
function isPassable(from, to) {
if (cells.f[from] !== cells.f[to]) return false; // on different islands
const queue = [from],
const passableQueue = [from],
used = new Uint8Array(cells.i.length),
state = cells.state[from];
while (queue.length) {
const current = queue.pop();
while (passableQueue.length) {
const current = passableQueue.pop();
if (current === to) return true; // way is found
cells.c[current].forEach(c => {
if (used[c] || cells.h[c] < 20 || cells.state[c] !== state) return;
queue.push(c);
passableQueue.push(c);
used[c] = 1;
});
}
Expand Down
8 changes: 4 additions & 4 deletions modules/religions-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ window.Religions = (function () {
const {cells, routes} = pack;
const religionIds = spreadFolkReligions(religions);

const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
const queue = new FlatQueue();
const cost = [];

// limit cost for organized religions growth
Expand All @@ -705,14 +705,14 @@ window.Religions = (function () {
.filter(r => r.i && !r.lock && r.type !== "Folk" && !r.removed)
.forEach(r => {
religionIds[r.center] = r.i;
queue.queue({e: r.center, p: 0, r: r.i, s: cells.state[r.center]});
queue.push({e: r.center, p: 0, r: r.i, s: cells.state[r.center]}, 0);
cost[r.center] = 1;
});

const religionsMap = new Map(religions.map(r => [r.i, r]));

while (queue.length) {
const {e: cellId, p, r, s: state} = queue.dequeue();
const {e: cellId, p, r, s: state} = queue.pop();
const {culture, expansion, expansionism} = religionsMap.get(r);

cells.c[cellId].forEach(nextCell => {
Expand All @@ -732,7 +732,7 @@ window.Religions = (function () {
if (cells.culture[nextCell]) religionIds[nextCell] = r; // assign religion to cell
cost[nextCell] = totalCost;

queue.queue({e: nextCell, p: totalCost, r, s: state});
queue.push({e: nextCell, p: totalCost, r, s: state}, totalCost);
}
});
}
Expand Down
16 changes: 8 additions & 8 deletions modules/zones-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,11 @@ window.Zones = (function () {
const cost = [];
const maxCells = rand(20, 40);

const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
queue.queue({e: burg.cell, p: 0});
const queue = new FlatQueue();
queue.push({e: burg.cell, p: 0}, 0);

while (queue.length) {
const next = queue.dequeue();
const next = queue.pop();
if (cells.burg[next.e] || cells.pop[next.e]) cellsArray.push(next.e);
usedCells[next.e] = 1;

Expand All @@ -224,7 +224,7 @@ window.Zones = (function () {

if (!cost[nextCellId] || p < cost[nextCellId]) {
cost[nextCellId] = p;
queue.queue({e: nextCellId, p});
queue.push({e: nextCellId, p}, p);
}
});
}
Expand All @@ -251,11 +251,11 @@ window.Zones = (function () {
const cost = [];
const maxCells = rand(5, 25);

const queue = new PriorityQueue({comparator: (a, b) => a.p - b.p});
queue.queue({e: burg.cell, p: 0});
const queue = new FlatQueue();
queue.push({e: burg.cell, p: 0}, 0);

while (queue.length) {
const next = queue.dequeue();
const next = queue.pop();
if (cells.burg[next.e] || cells.pop[next.e]) cellsArray.push(next.e);
usedCells[next.e] = 1;

Expand All @@ -266,7 +266,7 @@ window.Zones = (function () {

if (!cost[e] || p < cost[e]) {
cost[e] = p;
queue.queue({e, p});
queue.push({e, p}), p;
}
});
}
Expand Down
3 changes: 2 additions & 1 deletion versioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
*
* Example: 1.102.2 -> Major version 1, Minor version 102, Patch version 2
*/
const VERSION = "1.105.20";

const VERSION = "1.105.21";
if (parseMapVersion(VERSION) !== VERSION) alert("versioning.js: Invalid format or parsing function");

{
Expand Down