diff --git a/island/generators.ts b/island/generators.ts index 11c46e7..e2037ac 100644 --- a/island/generators.ts +++ b/island/generators.ts @@ -13,9 +13,7 @@ export const SMALL_MOUNTAIN: LobeGeneratorConstructor = (islands: IslandGrid, basePos: number) => () => { const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER); - const edgeTiles = islandTiles.filter( - (pos) => islands.data[pos] == WATER || islands.data[pos] == BEACH - ); + const edgeTiles = islandTiles.filter((pos) => islands.data[pos] <= BEACH); islands.dropWithin(edgeTiles); const mountainTiles = islands.floodSearch( @@ -44,7 +42,7 @@ export const SMALL_BEACH: LobeGeneratorConstructor = (islands: IslandGrid, basePos: number) => () => { 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); return true; @@ -59,7 +57,7 @@ export const BIG_BEACH: LobeGeneratorConstructor = ( return () => { 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); dropped++; @@ -74,7 +72,7 @@ export const SCATTERED_FOREST: LobeGeneratorConstructor = const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER); // grow shore - const shoreTiles = islandTiles.filter((pos) => islands.data[pos] == WATER); + const shoreTiles = islandTiles.filter((pos) => islands.data[pos] <= WATER); islands.dropWithin(shoreTiles); // seed beach @@ -98,7 +96,7 @@ export const CONTIGUOUS_FOREST: LobeGeneratorConstructor = const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER); // grow shore - const shoreTiles = islandTiles.filter((pos) => islands.data[pos] == WATER); + const shoreTiles = islandTiles.filter((pos) => islands.data[pos] <= WATER); islands.dropWithin(shoreTiles); // seed beach @@ -122,7 +120,7 @@ export const HILLY_FOREST: LobeGeneratorConstructor = const islandTiles = islands.floodSearch(basePos, (tile) => tile > WATER); // grow shore - const shoreTiles = islandTiles.filter((pos) => islands.data[pos] == WATER); + const shoreTiles = islandTiles.filter((pos) => islands.data[pos] <= WATER); islands.dropWithin(shoreTiles); // seed beach @@ -150,7 +148,7 @@ export const ERODED_BEACH: LobeGeneratorConstructor = (islands: IslandGrid, basePos: number) => () => { 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); // erode diff --git a/island/grid.ts b/island/grid.ts index 50b34aa..ed2697c 100644 --- a/island/grid.ts +++ b/island/grid.ts @@ -21,7 +21,7 @@ export class IslandGrid { done = false; 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); const islandBag = this.shuffle([