about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--lib/Octans/Neighbors.rakumod9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Octans/Neighbors.rakumod b/lib/Octans/Neighbors.rakumod
index c6f1c00..33dd834 100644
--- a/lib/Octans/Neighbors.rakumod
+++ b/lib/Octans/Neighbors.rakumod
@@ -20,10 +20,13 @@ sub neighbors (
     state Array @neighbors;
 
     if @puzzle[$y][$x] {
-
-        # If we've already computed the neighbors then no need to do
-        # it again.
+        # Don't re-compute neighbors.
         unless @neighbors[$y][$x] {
+            # Set it to an empty array because otherwise if it has no
+            # neighbors then it would've be recomputed everytime
+            # neighbors() was called.
+            @neighbors[$y][$x] = [];
+
             my Int $pos-x;
             my Int $pos-y;