Game of Life: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| Line 8: | Line 8: | ||
==Model Code Explanation== | ==Model Code Explanation== | ||
===.scn File=== | |||
===.sel File=== | |||
===.scn File=== | |||
/* This file contains a landscape event definition for Conway's Game of Life */ | |||
LSEVENT: GameOfLife | |||
DEFINITIONS | |||
LAYER: CellState, PrevCellState | |||
GLOBAL VARIABLE: pInitial | |||
ENDDEF | |||
INITIALSTATE | |||
INITIALSTATE = 1 | |||
CellState = IF UNIFORM(0,1) < pInitial THEN 1 ELSE 0 | |||
ENDIS | |||
RETURNTIME | |||
RETURNTIME = 1 | |||
PrevCellState = CellState | |||
ENDRT | |||
TRANSITIONS | |||
TRANSITIONS = TRUE | |||
numNeighbs = 0 | |||
OVER REGION CENTRED(1,1.5, EUCLIDEAN) | |||
DECISION PrevCellState EQ 1 | |||
numNeighbs = numNeighbs + 1 | |||
ENDFN | |||
CellState = IF (CellState EQ 0) AND (numNeighbs EQ 3) THEN 1 | |||
ELSE IF (CellState EQ 1) AND (2 <= numNeighbs <= 3) THEN 1 | |||
ELSE 0 | |||
ENDTR | |||
Revision as of 18:47, 8 November 2006
Summary
Summary here
Download Model
Download the .scn, .sel and .lse files by clicking on the following link: File:GameOfLife.zip
Model Code Explanation
.scn File
.sel File
.scn File
/* This file contains a landscape event definition for Conway's Game of Life */ LSEVENT: GameOfLife
DEFINITIONS
LAYER: CellState, PrevCellState GLOBAL VARIABLE: pInitial
ENDDEF
INITIALSTATE
INITIALSTATE = 1 CellState = IF UNIFORM(0,1) < pInitial THEN 1 ELSE 0
ENDIS
RETURNTIME
RETURNTIME = 1 PrevCellState = CellState
ENDRT
TRANSITIONS
TRANSITIONS = TRUE
numNeighbs = 0
OVER REGION CENTRED(1,1.5, EUCLIDEAN)
DECISION PrevCellState EQ 1
numNeighbs = numNeighbs + 1
ENDFN
CellState = IF (CellState EQ 0) AND (numNeighbs EQ 3) THEN 1
ELSE IF (CellState EQ 1) AND (2 <= numNeighbs <= 3) THEN 1
ELSE 0
ENDTR