The CA model

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.

Consume.scn
Seles Scenario Model.sel SimPriority Low Priority

Model.sel
Seles Model Time Units: Step kiloStep 1000 1000 Landscape Events: ConsumeCA.lse DEBUG Spatial Variables: LSState[3] PrevLSState[3] Legends: LSStateTypes = {0:Uncolonised, 1:Producer, 2:Consumer} Global Variables: pInitialProducer = 0.01 pInitialConsumer = 0.01 pSpreadProducer = 0.1 pSpreadConsumer = 0.2 pDeathProducer = 0.01 pDeathConsumer = 0.05 Output Frequency: 1

consumeCA.lse
// Producer/Consumer conceptual model implemented as a cellular automata // updating everything in a single event LSEVENT: ConsumeCA DEFINITIONS LAYER: LSState, PrevLSState GLOBAL CONSTANT: Uncolonised, Producer, Consumer GLOBAL VARIABLE: pInitialProducer, pInitialConsumer GLOBAL VARIABLE: pSpreadProducer, pDeathProducer, pSpreadConsumer, pDeathConsumer ENDDEF INITIALSTATE LSState = IF (UNIFORM(0,1) < pInitialConsumer) THEN Consumer ELSE IF (UNIFORM(0,1) < pInitialProducer) THEN Producer ELSE Uncolonised INITIALSTATE = 1 ENDIS RETURNTIME RETURNTIME = 1 PrevLSState = LSState ENDRT // Cellular automata: visit every cell and change state based on current state // and neighbourhood TRANSITIONS // An empty cell can possibly be colonised by a producer //  if it is next to at least one producer IF PrevLSState EQ Uncolonised OVER REGION CENTRED(1,1, WRAPPED) DECISION (PrevLSState EQ Producer) AND (UNIFORM(0,1) < pSpreadProducer) SOURCE LSState = Producer ENDFN // A producer can possibly die, or be eaten by a consumer ELSE IF PrevLSState EQ Producer IF (UNIFORM(0,1) < pDeathProducer) // mortality LSState = Uncolonised ELSE OVER REGION CENTRED(1,1, WRAPPED) DECISION (PrevLSState EQ Consumer) AND (UNIFORM(0,1) < pSpreadConsumer) SOURCE LSState = Consumer ENDFN ENDFN // A consumer may die ELSE // PrevLSState EQ Consumer IF UNIFORM(0,1) < pDeathConsumer LSState = Uncolonised ENDFN ENDFN TRANSITIONS = FALSE ENDTR

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