rh4_060829_GameOfLife_RulesAsFunction
' ---------------------------------------------------------------------------------
' Conway's Game of Life
' Rules:
' The universe of the GAME OF LIFE is an infinite two-dimensional grid of cells, each of which Is either alive Or dead.
' Cells interact With their eight neighbours, which are the cells that are directly horizontally, vertically, Or diagonally adjacent.
' At Each Step In Time, the following effects occur:
'
' 1. Any live cell With fewer than two neighbours dies, as If by loneliness.
' 2. Any live cell With more than three neighbours dies, as If by overcrowding.
' 3. Any live cell With two Or three neighbours lives, unchanged, To the Next generation.
' 4. Any dead cell With exactly three neighbours comes To life.
'
' The INITIAL PATTERN constitutes the first generation of the system.
' The Second generation Is created by applying the above rules simultaneously To every cell In the first generation
' -- births And deaths happen simultaneously, And the discrete moment at which this happens Is called a TICK.
' The rules continue To be applied repeatedly To create further generations.
' ---------------------------------------------------------------------------------
' ------------------------------------------------------
' [ CELLULAR AUTOMATON ]
' ------------------------------------------------------
Function newCell(arrCell,i,j)
' Check cell's neigbours
Dim total : total = neighboursCount(arrCell,i,j)
' [ RULES : GAME OF LIFE ]
If (arrCell(i,j) = 1) Then '---------if cell is ON
' LONELINESS: a cell with less than 2 adjoining cells dies
If (total < newcell =" 0"> 3) Then newCell = 0
' STASIS: a cell with exactly 2 adjoining cells remains the same
If (total = 2) Then newCell = 1
Else '---------if cell is OFF
' REPRODUCTION: an empty cell with more than 3 adjoining cells comes alive
If (total >= 3) Then newCell = 1
End If
End Function
' ---------------------------------------------------------------------------------