about summary refs log tree commit diff stats
path: root/js/baba-yaga/scratch/baba/life-simple.baba
diff options
context:
space:
mode:
Diffstat (limited to 'js/baba-yaga/scratch/baba/life-simple.baba')
-rw-r--r--js/baba-yaga/scratch/baba/life-simple.baba51
1 files changed, 51 insertions, 0 deletions
diff --git a/js/baba-yaga/scratch/baba/life-simple.baba b/js/baba-yaga/scratch/baba/life-simple.baba
new file mode 100644
index 0000000..b2da07c
--- /dev/null
+++ b/js/baba-yaga/scratch/baba/life-simple.baba
@@ -0,0 +1,51 @@
+// Simple Conway's Game of Life
+
+// Create a simple 3x3 blinker using individual variables
+c00 : 0; c01 : 1; c02 : 0;
+c10 : 0; c11 : 1; c12 : 0;  
+c20 : 0; c21 : 1; c22 : 0;
+
+// Count neighbors for center cell (1,1)
+neighbors11 : c00 + c01 + c02 + c10 + c12 + c20 + c21 + c22;
+
+// Apply Game of Life rules to center cell
+next11 : when (c11 = 1) is
+  true then when (neighbors11 = 2 or neighbors11 = 3) is true then 1 _ then 0
+  _ then when (neighbors11 = 3) is true then 1 _ then 0;
+
+// Count neighbors for top-left cell (0,0)  
+neighbors00 : c01 + c10 + c11;
+
+// Apply rules to top-left cell
+next00 : when (c00 = 1) is
+  true then when (neighbors00 = 2 or neighbors00 = 3) is true then 1 _ then 0
+  _ then when (neighbors00 = 3) is true then 1 _ then 0;
+
+// Count neighbors for top-center cell (0,1)
+neighbors01 : c00 + c02 + c10 + c11 + c12;
+
+// Apply rules to top-center cell  
+next01 : when (c01 = 1) is
+  true then when (neighbors01 = 2 or neighbors01 = 3) is true then 1 _ then 0
+  _ then when (neighbors01 = 3) is true then 1 _ then 0;
+
+// Display results
+io.out "Conway's Game of Life - Blinker Pattern";
+io.out "Generation 0:";
+io.out c00; io.out c01; io.out c02;
+io.out c10; io.out c11; io.out c12;
+io.out c20; io.out c21; io.out c22;
+
+io.out "Generation 1 (center cell):";
+io.out "Center cell neighbors:"; io.out neighbors11;
+io.out "Center cell next state:"; io.out next11;
+
+io.out "Generation 1 (top-left cell):";
+io.out "Top-left neighbors:"; io.out neighbors00;
+io.out "Top-left next state:"; io.out next00;
+
+io.out "Generation 1 (top-center cell):";
+io.out "Top-center neighbors:"; io.out neighbors01;
+io.out "Top-center next state:"; io.out next01;
+
+io.out "Done!";