Random Walker
Appearance
Summary
Screenshot
Download Model
Download the .scn, .sel and .lse files by clicking on the following link: File:RandomWalker.zip
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.
RandomWalker.scn
Seles Scenario RandomWalker.sel SimPriority Low Priority
RandomWalker.sel
Seles Model Model Size: 200, 200 Time Units: Step kiloStep 1000 1000 Landscape Events: RandomWalker.lse DEBUG Global Constants: MaxNumPresent = 100 Spatial Variables: NumPresent[MaxNumPresent] Global Variables: nInitial = MaxNumPresent Output Frequency: 1
RandomWalker.lse
/* This file contains a landscape agent definition for a random walker */
LSAGENT: RandomWalker
DEFINITIONS
LAYER: NumPresent
GLOBAL VARIABLE: nInitial
GLOBAL CONSTANT: MaxNumPresent
AGENT VARIABLE: LastDirection, StartLoc
ENDDEF
MOVELOCATION
REGION CENTRED(0,1.5,WRAPPED)
ENDML
INITIALSTATE
INITIALSTATE = 1
// nInitial = CLAMP(nInitial, 1, MaxNumPresent)
ENDIS
/*
AGENTLOCATION
REGION RECT(0,0,0,0)
ENDAL
*/
NUMAGENTS
NUMAGENTS = nInitial
NumPresent = MIN(NumPresent + 1, MaxNumPresent)
// Pick a start direction in one of the cardinal directions
LastDirection = 45 * FLOOR(UNIFORM(0,8))
StartLoc = Location
ENDNA
POPULATIONTIME
POPULATIONTIME = 1
PAUSE(50)
ENDPT
TRANSITIONS
TRANSITIONS = TRUE
ENDTR
MOVEPROB
// BEFORE MOVING: These expressions will be evaluated at
// all potential move locations
// For a correlated random walk
// For the current location, assume direction is the same
IF (Location EQ SOURCE Location)
dirDiff = 0
// Otherwise, compute the angel between the current direction and direction to this cell
ELSE
dirDiff = LastDirection - ROUND(DIRECTION(SOURCE Location, Location))
dirDiff = |dirDiff|
// Ensure we consider smallest angle between the two directions
dirDiff = IF dirDiff > 180 THEN 360 - dirDiff ELSE dirDiff
ENDFN
// MOVEPROB = IF dirDiff EQ 0 THEN 1 ELSE (1/dirDiff)^0.5
// MOVEPROB = 1/MAX(1,DISTANCE(Location, StartLoc))
MOVEPROB = 1
// AFTER MOVING: These expressions will be evaluated only
// at the chosen move location
SOURCE NumPresent = MAX(0,SOURCE NumPresent - 1)
NumPresent = MIN(NumPresent + 1, MaxNumPresent)
LastDirection = IF (Location EQ SOURCE Location) THEN LastDirection ELSE ROUND(DIRECTION(SOURCE Location, Location))
ENDMP
Suggested Experiments
To explore this cellular automata model further, try the following:
