about summary refs log tree commit diff
path: root/examples
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2022-02-06 16:15:00 +0100
committerMel <einebeere@gmail.com>2022-02-06 16:15:00 +0100
commit8abea71c7662016c98583a8d075a693eb4efa5e0 (patch)
tree40fcb3776b349ddef61788f737353508d6b27076 /examples
parent842e76d57274ea6f8d5929e96f2919fd9cf0afb5 (diff)
downloadrabbithole-8abea71c7662016c98583a8d075a693eb4efa5e0.tar.zst
rabbithole-8abea71c7662016c98583a8d075a693eb4efa5e0.zip
Update GoL example with newer constructs.
Diffstat (limited to 'examples')
-rw-r--r--examples/game_of_life.rh11
1 files changed, 4 insertions, 7 deletions
diff --git a/examples/game_of_life.rh b/examples/game_of_life.rh
index 118effb..e89aa27 100644
--- a/examples/game_of_life.rh
+++ b/examples/game_of_life.rh
@@ -1,5 +1,5 @@
-FIELD_WIDTH = 15;
-FIELD_HEIGHT = 15;
+FIELD_WIDTH := 15;
+FIELD_HEIGHT := 15;
 
 create_empty_field := fn {
     empty_row := [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
@@ -30,7 +30,6 @@ loop {
     loop if y < FIELD_HEIGHT {
         x = 0;
         loop if x < FIELD_WIDTH {
-            
             top := if y == 0 { 0 } else { field[y - 1][x] };
             top_left := if x == 0 || y == 0 { 0 } else { field[y - 1][x - 1] };
             top_right := if x == FIELD_WIDTH - 1 || y == 0 { 0 } else { field[y - 1][x + 1] };
@@ -48,10 +47,8 @@ loop {
                 if neighbors == 3 {
                     new_field[y][x] = 1;
                 };
-            } else {
-                if neighbors == 2 || neighbors == 3 {
-                    new_field[y][x] = 1;
-                };
+            } elif neighbors == 2 || neighbors == 3 {
+                new_field[y][x] = 1;
             };
 
             x = x + 1;