prepare to merge, add comments, remove fluff

This commit is contained in:
Mészáros Gergely 2022-04-13 17:58:49 +02:00
parent f99edae5db
commit 7e02d40066
3 changed files with 25 additions and 20 deletions

19
main.js
View file

@ -1635,18 +1635,13 @@ function addZones(number = 1) {
cellsArray.push(q);
if (cellsArray.length > power) break;
try {
cells.c[q].forEach(e => {
if (used[e]) return;
if (cells.state[e] !== state.i) return;
used[e] = 1;
if (e % 4 !== 0 && !cells.c[e].some(c => cells.state[c] === neib)) return;
queue.push(e);
});
} catch (er) {
console.error('Error in rebel generation: ', q, cellsArray);
throw er;
}
cells.c[q].forEach(e => {
if (used[e]) return;
if (cells.state[e] !== state.i) return;
used[e] = 1;
if (e % 4 !== 0 && !cells.c[e].some(c => cells.state[c] === neib)) return;
queue.push(e);
});
}
const rebels = rw({Rebels: 5, Insurgents: 2, Mutineers: 1, Rioters: 1, Separatists: 1, Secessionists: 1, Insurrection: 2, Rebellion: 1, Conspiracy: 2});

View file

@ -35,13 +35,11 @@ window.Rivers = (function () {
TIME && console.timeEnd("generateRivers");
function drainWater() {
const pixel2 = distanceScale * distanceScale
//const MIN_FLUX_TO_FORM_RIVER = 10 * distanceScale;
const MIN_FLUX_TO_FORM_RIVER = 30;
const cellsNumberModifier = (pointsInput.dataset.cells / 10000) ** 0.25;
const prec = grid.cells.prec;
// const area = c => pack.cells.area[c] * pixel2;
const area = pack.cells.area;
const land = cells.i.filter(i => h[i] >= 20).sort((a, b) => h[b] - h[a]);
const lakeOutCells = Lakes.setClimateData(h);

View file

@ -1,17 +1,29 @@
"use strict";
/*
Experimental submaping module
Cell resampler module used by submapper and resampler (transform)
main function: resample(options);
*/
window.Submap = (function () {
const isWater = (map, id) => map.grid.cells.h[map.pack.cells.g[id]] < 20? true: false;
const inMap = (x,y) => x>0 && x<graphWidth && y>0 && y<graphHeight;
function resample(parentMap, options) {
// generate new map based on an existing one (resampling parentMap)
// parentMap: {seed, grid, pack} from original map
// projection: map function from old to new coordinates or backwards
// prj(x,y,direction:bool) -> [x',y']
function resample(parentMap, options) { /*
generate new map based on an existing one (resampling parentMap)
parentMap: {seed, grid, pack} from original map
options = {
projection: f(Number,Number)->[Number, Number]
function to calculate new coordinates
inverse: g(Number,Number)->[Number, Number]
inverse of f
depressRivers: Bool carve out riverbeds?
smoothHeightMap: Bool run smooth filter on heights
addLakesInDepressions: call FMG original funtion on heightmap
lockMarkers: Bool Auto lock all copied markers
lockBurgs: Bool Auto lock all copied burgs
}
*/
const projection = options.projection;
const inverse = options.inverse;