(define "Nbors" (count Sites in:(intersection (sites Around #1) (sites Occupied by:All) ) ) ) (define "Grow" (forEach Site (sites Board) (if (and (is Empty (to)) (= 3 ("Nbors" (to))) ) (add (piece "Disc") (to (to))) (if (and (is Occupied (to)) (or (< ("Nbors" (to)) 2) (> ("Nbors" (to)) 3)) ) (remove (to)) ) ) ) ) //------------------------------------------------------------------------------ (game "Game of Life" (players 0) (equipment { (board ) (piece "Disc" Shared) }) (rules (start (place "Disc" (sites {}))) (play ("Grow") ) (end (if (= (count Moves) 100) (result Mover Draw))) ) ) //------------------------------------------------------------------------------ (option "Board" args:{ } { (item "Square 8x8" <(square 8)> "Square 8x8 board.") (item "Square 12x12" <(square 12)> "Square 12x12 board.")* (item "Hex 5" <(hex 5)> "Hex 5 board.") }) (option "Start" args:{ } { (item "Glider" <"B4" "C4" "D4" "D3" "C2"> "Self-perpetuating glider pattern." ) (item "Lightweight Spaceship" <"C3" "D3" "E3" "F3" "B4" "F4" "F5" "C6" "E6"> "Self-perpetuating Lightweight spaceship pattern." )* (item "Blinker" <"B3" "C3" "D3"> "Oscillating blinker pattern." ) (item "Toad" <"B3" "C3" "D3" "C4" "D4" "E4"> "Oscillating toad pattern." ) (item "Beacon" <"B2" "C2" "B3" "C3" "D4" "E4" "D5" "E5"> "Oscillating beacon pattern." ) (item "Block" <"B2" "C2" "B3" "C3"> "Static block pattern." ) }) //------------------------------------------------------------------------------ (metadata (info { (description "Board game version of Conway's Game of Life.") (rules "At each tick, a set of rules are applied to every board cell, which determine whether a piece 'lives' or 'dies' at each cell. Any live cell with two or three live neighbours survives. Any dead cell with three live neighbours becomes a live cell. All other live cells die in the next generation. Similarly, all other dead cells stay dead.") (id "708") (source "Wikipedia") (version "1.3.14") (classification "simulation") (author "John Horton Conway") (credit "Eric Piette and Cameron Browne") (date "1970") } ) )