Fur
Model was written in NetLogo 5.0.4
•
Viewed 555 times
•
Downloaded 99 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Info tab cannot be displayed because of an encoding error
Comments and Questions
Click to Run Model
patches-own [ new-color ;; currently, always either white or black inner-neighbors ;; other cells in a circle around the cell outer-neighbors ;; other cells in a ring around the cell (but usually not touching the cell) ] to setup clear-all ;; computes inner and outer neighbors in an ellipse around each cell ask patches [ set inner-neighbors ellipse-in inner-radius-x inner-radius-y ;; outer-neighbors needs more computation because we want only the cells in the circular ring set outer-neighbors ellipse-ring outer-radius-x outer-radius-y inner-radius-x inner-radius-y ] ifelse any? patches with [ count outer-neighbors = 0 ] [ user-message word "It doesn't make sense that 'outer' is equal to or smaller than 'inner.' " " Please reset the sliders and press Setup again." stop] [restart] reset-ticks end ;; this procedure sets approximately initial-density percent of the ;; cells white and the rest black; if initial-density is set at 50% ;; then about half the cells will be white and the rest black to restart ask patches [ ifelse random-float 100.0 < initial-density [ set pcolor white ] [ set pcolor black ] ] reset-ticks end to go ask patches [ pick-new-color ] ask patches [ set pcolor new-color ] tick end to pick-new-color ;; patch procedure let activator count inner-neighbors with [pcolor = white] let inhibitor count outer-neighbors with [pcolor = white] ;; we don't need to multiply 'activator' by a coefficient because ;; the ratio variable keeps the proportion intact let difference activator - ratio * inhibitor ifelse difference > 0 [ set new-color white ] [ if difference < 0 [ set new-color black ] ] ;; note that we did not deal with the case that difference = 0. ;; this is because we would then want cells not to change color. end ;;; procedures for defining elliptical neighborhoods to-report ellipse-in [x-radius y-radius] ;; patch procedure report patches in-radius (max list x-radius y-radius) with [1.0 >= ((xdistance myself ^ 2) / (x-radius ^ 2)) + ((ydistance myself ^ 2) / (y-radius ^ 2))] end to-report ellipse-ring [outx-radius outy-radius inx-radius iny-radius] ;; patch procedure report patches in-radius (max list outx-radius outy-radius) with [1.0 >= ((xdistance myself ^ 2) / (outx-radius ^ 2)) + ((ydistance myself ^ 2) / (outy-radius ^ 2)) and 1.0 < ((xdistance myself ^ 2) / (inx-radius ^ 2)) + ((ydistance myself ^ 2) / (iny-radius ^ 2)) ] end ;; The following two reporter give us the x and y distance magnitude. ;; you can think of a point at the tip of a triangle determining how much ;; "to the left" it is from another point and how far "over" it is from ;; that same point. These two numbers are important for computing total distances ;; in elliptical "neighborhoods." ;; Note that it is important to use the DISTANCEXY primitive and not ;; just take the absolute value of the difference in coordinates, ;; because DISTANCEXY handles wrapping around world edges correctly, ;; if wrapping is enabled (which it is by default in this model) to-report xdistance [other-patch] ;; patch procedure report distancexy [pxcor] of other-patch pycor end to-report ydistance [other-patch] ;; patch procedure report distancexy pxcor [pycor] of other-patch end ; Copyright 2003 Uri Wilensky. ; See Info tab for full copyright and license.
There are 10 versions of this model.
Attached files
File | Type | Description | Last updated | |
---|---|---|---|---|
Fur.png | preview | Preview for 'Fur' | over 11 years ago, by Uri Wilensky | Download |
This model does not have any ancestors.
This model does not have any descendants.