BehaviorSpace Example

No preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

(This model has yet to be categorized with any tags)
Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 4.1RC2 • Viewed 634 times • Downloaded 52 times • Run 4 times
Download the 'BehaviorSpace Example' modelDownload this modelEmbed this model

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

patches-own [
  living?         ;; indicates if the cell is living
  live-neighbors  ;; counts how many neighboring cells are alive
]

to setup-blank
  reset-ticks
  ask patches
    [ cell-death ]
end 

to setup-random
  reset-ticks
  ask patches
    [ ifelse random-float 100.0 < initial-density
        [ cell-birth ]
        [ cell-death ] ]
end 

to cell-birth
  set living? true
  set pcolor fgcolor
end 

to cell-death
  set living? false
  set pcolor bgcolor
end 

to go
  if mouse-down?
    [ stop ]  ;; wait for user to stop drawing
  ask patches
    [ set live-neighbors count neighbors with [living?] ]
  ;; Starting a new "ask patches" here ensures that all the patches
  ;; finish executing the first ask before any of them start executing
  ;; the second ask.  This keeps all the patches in sync with each other,
  ;; so the births and deaths at each generation all happen in lockstep.
  ask patches
    [ ifelse live-neighbors = 3
        [ cell-birth ]
        [ if live-neighbors != 2
            [ cell-death ] ] ]
  tick
end 

to add-cells
  if mouse-down?
    [ ask patch mouse-xcor mouse-ycor
        [ cell-birth ] ]
  display
end 

to remove-cells
  if mouse-down?
    [ ask patch mouse-xcor mouse-ycor
        [ cell-death ] ]
  display
end 

There are 3 versions of this model.

Uploaded by When Description Download
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago BehaviorSpace Example Download this version
Uri Wilensky over 14 years ago BehaviorSpace Example Download this version

Attached files

No files

This model does not have any ancestors.

This model does not have any descendants.