Init to deep water - cool results, but slow
This commit is contained in:
parent
dc8fc5ef87
commit
2b37385439
2 changed files with 8 additions and 10 deletions
|
@ -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
|
||||||
|
|
|
@ -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([
|
||||||
|
|
Loading…
Add table
Reference in a new issue