Behavior spread
Model was written in NetLogo 6.1.1
•
Viewed 475 times
•
Downloaded 16 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
;; ;; Global variables. ;; globals [count_MS0 count_MS1 ticks_MS01] ;; ;; turtle/breed. ;; ;; ;; turtle/breed variables. ;; turtles-own [ MS ;; mental state OB ;; observed behavior OBD ;; observed behavior discrepancy ] ;; ;; setup. ;; to setup clear-all reset-ticks setup-world setup-turtles ;; etc end ;; ;; setup-world. ;; to setup-world ask patches [ set pcolor green + 2] end ;; ;; setup-turtles. ;; to setup-turtles ;; Initialize global variables. ;; Create the turtles and set their initial states. create-turtles number_agents [ set shape "default" setxy random-xcor random-ycor] ;; Initial MS. ask turtles [ ifelse random 100 < MS1 [ set MS 1 set color 9.9] [ set MS 0 set color 0 ] ] ;; Update counts. update-counts end ;; ;; go. ;; to go ;; Criteria to stop. if (ticks > 5000) [stop] if (count_MS0 = count_MS1) [stop] ;; Otherwise do-things. ;; Update status. update-turtles ;; tick. tick end ;; ;; update-turtles. ;; to update-turtles ask turtles [ ;; update MS after wear let WR (WR0 + (WR1 - WR0) * MS) if random-float 100 < WR [ ifelse MS = 0 [set MS 1] [set MS 0]] ;; update OB ifelse (MS = 1) [ set OB sqrt(random-float 1.)] [ set OB (1 - sqrt(1 - (random-float 1.)))] ;; update OBD set OBD (MS - mean [OB] of other n-of K turtles) ;; update MS after OBD ;; triangular distribution for given MS: let x0 MS - 1 let x1 MS let xm 2 * MS - 1 ;; position of the mode let ym (PC0 + (PC1 - PC0) * MS) * 2 ;; compute y (given MS and OBD): let y 0 ifelse (OBD < xm) [ ifelse ( xm = x0) [ set y ym] [ set y 0 + (OBD - x0) * ym / (xm - x0)] ] [ ifelse ( xm = x1) [ set y ym] [ set y 0 + (x1 - OBD) * ym / (x1 - xm)] ] ;; Change MS according to y if random-float 100 < y * 0.1 ;; 0.1 is the interval precision width for OBD. [ ifelse MS = 0 [set MS 1] [set MS 0]] ;; Update counts. update-counts ;; update color ifelse MS = 0 [set color 0] [set color 9.9] ] end to update-counts ;; Update counts. set count_MS0 count turtles with [MS = 0] set count_MS1 count turtles with [MS = 1] end
There is only one version of this model, created over 4 years ago by Ricardo Gonzalez.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Behavior spread.png | preview | Preview for 'Behavior spread' | over 4 years ago, by Ricardo Gonzalez | Download |
This model does not have any ancestors.
This model does not have any descendants.