Init to deep water - cool results, but slow

This commit is contained in:
Tangent Wantwight 2024-01-13 15:02:43 -05:00
parent dc8fc5ef87
commit 2b37385439
2 changed files with 8 additions and 10 deletions

View file

@ -13,9 +13,7 @@ export const SMALL_MOUNTAIN: LobeGeneratorConstructor =
(islands: IslandGrid, basePos: number) => () => { (islands: IslandGrid, basePos: number) => () => {
const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER); const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER);
const edgeTiles = islandTiles.filter( const edgeTiles = islandTiles.filter((pos) => islands.data[pos] <= BEACH);
(pos) => islands.data[pos] == WATER || islands.data[pos] == BEACH
);
islands.dropWithin(edgeTiles); islands.dropWithin(edgeTiles);
const mountainTiles = islands.floodSearch( const mountainTiles = islands.floodSearch(
@ -44,7 +42,7 @@ export const SMALL_BEACH: LobeGeneratorConstructor =
(islands: IslandGrid, basePos: number) => () => { (islands: IslandGrid, basePos: number) => () => {
const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER); const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER);
const shoreTiles = islandTiles.filter((pos) => islands.data[pos] == WATER); const shoreTiles = islandTiles.filter((pos) => islands.data[pos] <= WATER);
islands.dropWithin(shoreTiles); islands.dropWithin(shoreTiles);
return true; return true;
@ -59,7 +57,7 @@ export const BIG_BEACH: LobeGeneratorConstructor = (
return () => { return () => {
const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER); const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER);
const shoreTiles = islandTiles.filter((pos) => islands.data[pos] == WATER); const shoreTiles = islandTiles.filter((pos) => islands.data[pos] <= WATER);
islands.dropWithin(shoreTiles); islands.dropWithin(shoreTiles);
dropped++; dropped++;
@ -74,7 +72,7 @@ export const SCATTERED_FOREST: LobeGeneratorConstructor =
const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER); const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER);
// grow shore // grow shore
const shoreTiles = islandTiles.filter((pos) => islands.data[pos] == WATER); const shoreTiles = islandTiles.filter((pos) => islands.data[pos] <= WATER);
islands.dropWithin(shoreTiles); islands.dropWithin(shoreTiles);
// seed beach // seed beach
@ -98,7 +96,7 @@ export const CONTIGUOUS_FOREST: LobeGeneratorConstructor =
const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER); const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER);
// grow shore // grow shore
const shoreTiles = islandTiles.filter((pos) => islands.data[pos] == WATER); const shoreTiles = islandTiles.filter((pos) => islands.data[pos] <= WATER);
islands.dropWithin(shoreTiles); islands.dropWithin(shoreTiles);
// seed beach // seed beach
@ -122,7 +120,7 @@ export const HILLY_FOREST: LobeGeneratorConstructor =
const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER); const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER);
// grow shore // grow shore
const shoreTiles = islandTiles.filter((pos) => islands.data[pos] == WATER); const shoreTiles = islandTiles.filter((pos) => islands.data[pos] <= WATER);
islands.dropWithin(shoreTiles); islands.dropWithin(shoreTiles);
// seed beach // seed beach
@ -150,7 +148,7 @@ export const ERODED_BEACH: LobeGeneratorConstructor =
(islands: IslandGrid, basePos: number) => () => { (islands: IslandGrid, basePos: number) => () => {
const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER); const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER);
const shoreTiles = islandTiles.filter((pos) => islands.data[pos] == WATER); const shoreTiles = islandTiles.filter((pos) => islands.data[pos] <= WATER);
islands.dropWithin(shoreTiles); islands.dropWithin(shoreTiles);
// erode // erode

View file

@ -21,7 +21,7 @@ export class IslandGrid {
done = false; done = false;
constructor(public width: number, public height: number, seed: number) { constructor(public width: number, public height: number, seed: number) {
this.data = Array(width * height).fill(0); this.data = Array(width * height).fill(-1);
this.rng = mulberry32(seed); this.rng = mulberry32(seed);
const islandBag = this.shuffle([ const islandBag = this.shuffle([