more porting work

This commit is contained in:
barrulus 2025-08-05 13:12:07 -04:00
parent 37391c8e8b
commit 7f31969f50
38 changed files with 3673 additions and 463 deletions

View file

@ -1,6 +1,34 @@
"use strict";
/**
* Generates burgs (settlements) and states (political entities)
*
* REQUIRES:
* - pack.cells.culture (from cultures module)
* - pack.cells.s (from cell ranking)
* - pack.cultures (from cultures module)
* - config.statesNumber (number of states to generate)
*
* PROVIDES:
* - pack.burgs (burgs array)
* - pack.states (states array)
* - pack.cells.burg (burg assignments)
* - pack.cells.state (state assignments)
*/
export const generate = (pack, grid, config, utils) => {
// Check required properties exist
if (!pack.cells.culture) {
throw new Error("BurgsAndStates module requires cells.culture from Cultures module");
}
if (!pack.cells.s) {
throw new Error("BurgsAndStates module requires cells.s (suitability) from Cell ranking");
}
if (!pack.cultures) {
throw new Error("BurgsAndStates module requires pack.cultures from Cultures module");
}
if (!config.statesNumber) {
throw new Error("BurgsAndStates module requires config.statesNumber");
}
const {cells, cultures} = pack;
const n = cells.i.length;