From 3019a8b713057e95430d37cc8bc7eec2c337beb9 Mon Sep 17 00:00:00 2001
From: Tangent Wantwight <tangent128@gmail.com>
Date: Fri, 12 Jan 2024 23:25:09 -0500
Subject: [PATCH] add diagonals to "downhill" check

---
 island.ts | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

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() {