123 preview image

1 collaborator

Default-person jihyeon kim (Author)


(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.0.4 • Viewed 640 times • Downloaded 38 times • Run 0 times
Download the '123' modelDownload this modelEmbed this model

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

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

  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
  ;; 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."

;; 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 ] ]

to go
  ask patches [ pick-new-color ]
  ask patches [ set pcolor new-color ]

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.

;;; 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))]

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))

;; 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

to-report ydistance [other-patch]  ;; patch procedure
  report distancexy pxcor
                    [pycor] of other-patch

; Copyright 2003 Uri Wilensky.
; See Info tab for full copyright and license.

There is only one version of this model, created about 10 years ago by jihyeon kim.

Attached files

File Type Description Last updated
123.png preview Preview for '123' about 10 years ago, by jihyeon kim Download

This model does not have any ancestors.

This model does not have any descendants.