diff --git a/island.ts b/island.ts index 49748aa..1576e62 100644 --- a/island.ts +++ b/island.ts @@ -124,6 +124,8 @@ export function IslandApplet() { } } + // try to roll in cardinal directions + check((pos - width) % len); check((pos - 1) % len); check((pos + 1) % len); @@ -131,10 +133,23 @@ export function IslandApplet() { if (lowerNeighbors.length > 0) { const downhill = lowerNeighbors[islands.rng() % lowerNeighbors.length]; - drop(downhill); - } else { - islands.data[pos]++; + return drop(downhill); } + + // try to roll in diagonal directions + + check((pos - width - 1) % len); + check((pos - width + 1) % len); + check((pos + width - 1) % len); + check((pos + width + 1) % len); + + if (lowerNeighbors.length > 0) { + const downhill = lowerNeighbors[islands.rng() % lowerNeighbors.length]; + return drop(downhill); + } + + // flat, increase elevation + islands.data[pos]++; } function tick() {