Markov chains

Download Model
Download the .scn, .sel and .lse files by clicking on the following link:

Model Code Exploration
In the following sections we will examine all of the model files for this model. Note that instead of downloading the zip file above, you could just copy the text in the boxes below into a text editor and save it with the appropriate name (Section title). Opening the resulting .scn file in the SELES simulator would run this model.

MarkovChain.scn
SELES Scenario MarkovChain.sel SimPriority Low Priority

MarkovChain.sel
Seles Model Model Size: 200, 200 Time Units: na Step 1 1000 Landscape Events: MarkovChain.lse Spatial Variables: CellState[4] <= 0 PrevCellState[4] <= 0 Global Variables: pInitial = 0, 1, 0, 0, 0 pChange = 0.01 UseNeighbs = FALSE Output Frequency: 1

MarkovChain.lse
// Simple Markov Chain LSEVENT: MarkovChain DEFINITIONS LAYER: CellState, PrevCellState GLOBAL VARIABLE: pInitial[], pChange, UseNeighbs ENDDEF INITIALSTATE INITIALSTATE = 1 CellState = CLASSIFIED_DIST[pInitial] ENDIS RETURNTIME RETURNTIME = 1 PrevCellState = CellState ENDRT TRANSITIONS TRANSITIONS = TRUE IF UseNeighbs n = 0 t = 0 x = PrevCellState OVER REGION CENTRED(0, 1.5) n = n + 1 t = t + PrevCellState x = IF (PrevCellState EQ 0) OR (x EQ 0) THEN 0 ELSE MAX(x, PrevCellState) ENDFN currState = CLAMP(ROUND(t/n), 0, 4) currState = x  ELSE currState = PrevCellState ENDFN CellState = CLASSIFY(currState) 0: 0               1: CLASSIFIED_DIST 1:1 - pChange 2:pChange ENDFN 2: CLASSIFIED_DIST 2:1 - pChange 3:pChange ENDFN 3: CLASSIFIED_DIST 3:1 - pChange 4:pChange ENDFN 4: CLASSIFIED_DIST 0: pChange 4:1 - pChange ENDFN ENDFN ENDTR

Suggested Experiments
To explore this cellular automata model further, try the following: