diff options
Diffstat (limited to 'js/baba-yaga/scratch/baba/life-final.baba')
-rw-r--r-- | js/baba-yaga/scratch/baba/life-final.baba | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/js/baba-yaga/scratch/baba/life-final.baba b/js/baba-yaga/scratch/baba/life-final.baba new file mode 100644 index 0000000..a489c89 --- /dev/null +++ b/js/baba-yaga/scratch/baba/life-final.baba @@ -0,0 +1,59 @@ +// Conway's Game of Life - Final Working Demo + +// Simple blinker pattern - just show the concept + +// Initial state: 3 cells in a vertical line +top : 1; +middle : 1; +bottom : 1; + +io.out "Conway's Game of Life - Blinker Pattern"; +io.out "=========================================="; + +io.out "Generation 0 (vertical line):"; +io.out " .#."; +io.out " .#."; +io.out " .#."; + +io.out ""; +io.out "Applying Game of Life rules..."; + +// Count neighbors for middle cell +middleNeighbors : top + bottom; // 2 neighbors (top and bottom) + +// Apply rules: live cell with 2-3 neighbors survives +middleNext : when (middle = 1 and (middleNeighbors = 2 or middleNeighbors = 3)) is + true then 1 + _ then 0; + +// Count neighbors for left and right of middle row (each has 3 neighbors) +leftNeighbors : 3; // top, middle, bottom +rightNeighbors : 3; // top, middle, bottom + +// Apply rules: dead cell with exactly 3 neighbors becomes alive +leftNext : when (leftNeighbors = 3) is true then 1 _ then 0; +rightNext : when (rightNeighbors = 3) is true then 1 _ then 0; + +io.out "Generation 1 (horizontal line):"; +io.out " ..."; +io.out " ###"; +io.out " ..."; + +io.out ""; +io.out "Neighbor counts:"; +io.out "Middle cell had neighbors:"; io.out middleNeighbors; +io.out "Middle cell survives:"; io.out middleNext; +io.out "Left cell becomes alive:"; io.out leftNext; +io.out "Right cell becomes alive:"; io.out rightNext; + +io.out ""; +io.out "The pattern oscillates between:"; +io.out "Vertical: .#. Horizontal: ..."; +io.out " .#. ###"; +io.out " .#. ..."; + +io.out ""; +io.out "This demonstrates Conway's Game of Life!"; +io.out "Rules: Live cell with 2-3 neighbors survives"; +io.out " Dead cell with exactly 3 neighbors becomes alive"; +io.out " All other cells die or stay dead"; |