Random Walker: Difference between revisions
Appearance
No edit summary |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 4: | Line 4: | ||
==Screenshot== | ==Screenshot== | ||
[[Image: | [[Image:NumPresent.gif]] | ||
==Download Model== | ==Download Model== | ||
Download the .scn, .sel and .lse files by clicking on the following link: [[Image: | Download the .scn, .sel and .lse files by clicking on the following link: [[Image:RandomWalker.zip]] | ||
==Model Code Exploration== | ==Model Code Exploration== | ||
| Line 14: | Line 14: | ||
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. | 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 | Seles Scenario | ||
RandomWalker.sel | |||
SimPriority Low Priority | SimPriority Low Priority | ||
=== | ===RandomWalker.sel=== | ||
Seles Model | Seles Model | ||
Model Size: 200, 200 | |||
Time Units: Step kiloStep 1000 1000 | Time Units: Step kiloStep 1000 1000 | ||
Landscape Events: | Landscape Events: | ||
RandomWalker.lse DEBUG | |||
Global Constants: | |||
MaxNumPresent = 100 | |||
Spatial Variables: | Spatial Variables: | ||
NumPresent[MaxNumPresent] | |||
Global Variables: | Global Variables: | ||
nInitial = MaxNumPresent | |||
Output Frequency: 1 | Output Frequency: 1 | ||
=== | ===RandomWalker.lse=== | ||
/* This file contains a landscape agent definition for a random walker */ | |||
LSAGENT: RandomWalker | |||
DEFINITIONS | DEFINITIONS | ||
LAYER: | LAYER: NumPresent | ||
GLOBAL CONSTANT: | GLOBAL VARIABLE: nInitial | ||
GLOBAL CONSTANT: MaxNumPresent | |||
AGENT VARIABLE: LastDirection, StartLoc | |||
ENDDEF | 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 | ||
TRANSITIONS = TRUE | |||
TRANSITIONS = | |||
ENDTR | 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 | 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== | ==Suggested Experiments== | ||
To explore this cellular automata model further, try the following: | To explore this cellular automata model further, try the following: | ||
Latest revision as of 17:41, 14 November 2006
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:
