Life Turtle-Based

Life Turtle-Based preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

cellular automata 

Tagged by Reuven M. Lerner over 11 years ago

computer science 

Tagged by Reuven M. Lerner over 11 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 685 times • Downloaded 74 times • Run 2 times
Download the 'Life Turtle-Based' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


## WHAT IS IT?

This model is the same as the Life model, but with a more attractive display. This display is achieved by basing the model on turtles rather than patches.

This program is an example of a two-dimensional cellular automaton. This particular cellular automaton is called The Game of Life.

A cellular automaton is a computational machine that performs actions based on certain rules. It can be thought of as a board which is divided into cells (such as square cells of a checkerboard). Each cell can be either "alive" or "dead." This is called the "state" of the cell. According to specified rules, each cell will be alive or dead at the next time step.

## HOW IT WORKS

The rules of the game are as follows. Each cell checks the state of itself and its eight surrounding neighbors and then sets itself to either alive or dead. If there are less than two alive neighbors, then the cell dies. If there are more than three alive neighbors, the cell dies. If there are 2 alive neighbors, the cell remains in the state it is in. If there are exactly three alive neighbors, the cell becomes alive. This is done in parallel and continues forever.

There are certain recurring shapes in Life, for example, the "glider" and the "blinker". The glider is composed of 5 cells which form a small arrow-headed shape, like this:

O

O

OOO

This glider will wiggle across the world, retaining its shape. A blinker is a group of three cells (either up and down or left and right) that rotates between horizontal and vertical orientations.

## HOW TO USE IT

The INITIAL-DENSITY slider determines the initial density of cells that are alive. SETUP-RANDOM places these cells. GO-FOREVER runs the rule forever. GO-ONCE runs the rule once.

As the model runs, a small green dot indicates where a cell will be born, but is not treated as a live cell. Grey cells are cells that are about to die, but are treated as live cells.

If you want to draw your own pattern, press the DRAW-CELLS button and then use the mouse to "draw" and "erase" in the view.

CURRENT DENSITY is the percent of cells that are on.

## THINGS TO NOTICE

Find some objects that are alive, but motionless.

Is there a "critical density" - one at which all change and motion stops/eternal motion begins?

## THINGS TO TRY

Are there any recurring shapes other than gliders and blinkers?

Build some objects that don't die (using DRAW-CELLS)

How much life can the board hold and still remain motionless and unchanging? (use DRAW-CELLS)

The glider gun is a large conglomeration of cells that repeatedly spits out gliders. Find a "glider gun" (very, very difficult!).

## EXTENDING THE MODEL

Give some different rules to life and see what happens.

Experiment with using `neighbors4` instead of `neighbors` (see below).

## NETLOGO FEATURES

The `neighbors` primitive returns the agentset of the patches to the north, south, east, west, northeast, northwest, southeast, and southwest.

`neighbors4` is like `neighbors` but only uses the patches to the north, south, east, and west. Some cellular automata, like this one, are defined using the 8-neighbors rule, others the 4-neighbors.

## RELATED MODELS

Life --- same as this, but implemented using only patches, not turtles

CA 1D Elementary --- a model that shows all 256 possible simple 1D cellular automata

CA 1D Totalistic --- a model that shows all 2,187 possible 1D 3-color totalistic cellular automata

CA 1D Rule 30 --- the basic rule 30 model

CA 1D Rule 30 Turtle --- the basic rule 30 model implemented using turtles

CA 1D Rule 90 --- the basic rule 90 model

CA 1D Rule 110 --- the basic rule 110 model

CA 1D Rule 250 --- the basic rule 250 model

## CREDITS AND REFERENCES

The Game of Life was invented by John Horton Conway.

See also:

Von Neumann, J. and Burks, A. W., Eds, 1966. Theory of Self-Reproducing Automata. University of Illinois Press, Champaign, IL.

"LifeLine: A Quarterly Newsletter for Enthusiasts of John Conway's Game of Life", nos. 1-11, 1971-1973.

Martin Gardner, "Mathematical Games: The fantastic combinations of John Conway's new solitaire game `life',", Scientific American, October, 1970, pp. 120-123.

Martin Gardner, "Mathematical Games: On cellular automata, self-reproduction, the Garden of Eden, and the game `life',", Scientific American, February, 1971, pp. 112-117.

Berlekamp, Conway, and Guy, Winning Ways for your Mathematical Plays, Academic Press: New York, 1982.

William Poundstone, The Recursive Universe, William Morrow: New York, 1985.

## HOW TO CITE

If you mention this model in a publication, we ask that you include these citations for the model itself and for the NetLogo software:

* Wilensky, U. (2005). NetLogo Life Turtle-Based model. http://ccl.northwestern.edu/netlogo/models/LifeTurtle-Based. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.

* Wilensky, U. (1999). NetLogo. http://ccl.northwestern.edu/netlogo/. Center for Connected Learning and Computer-Based Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.

## COPYRIGHT AND LICENSE

Copyright 2005 Uri Wilensky.

![CC BY-NC-SA 3.0](http://i.creativecommons.org/l/by-nc-sa/3.0/88x31.png)

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License. To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Commercial licenses are also available. To inquire about commercial licenses, please contact Uri Wilensky at uri@northwestern.edu.

Comments and Questions

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

Click to Run Model

breed [cells cell]    ;; living cells
breed [babies baby]   ;; show where a cell will be born

patches-own [
  live-neighbors  ;; count of how many neighboring cells are alive
]

to setup-blank
  clear-all
  set-default-shape cells "circle"
  set-default-shape babies "dot"
  ask patches
    [ set live-neighbors 0 ]
  reset-ticks
end 

to setup-random
  setup-blank
  ;; create initial babies
  ask patches
    [ if random-float 100.0 < initial-density
      [ sprout-babies 1 ] ]
  ;; grow the babies into adult cells
  go
  reset-ticks  ;; set the tick counter back to 0
end 

;; this procedure is called when a cell is about to become alive

to birth  ;; patch procedure
  sprout-babies 1
  [ ;; soon-to-be-cells are lime
    set color lime + 1 ]  ;; + 1 makes the lime a bit lighter
end 

to go
  ;; get rid of the dying cells from the previous tick
  ask cells with [color = gray]
    [ die ]
  ;; babies become alive
  ask babies
    [ set breed cells
      set color white ]
  ;; All the live cells count how many live neighbors they have.
  ;; Note we don't bother doing this for every patch, only for
  ;; the ones that are actually adjacent to at least one cell.
  ;; This should make the program run faster.
  ask cells
    [ ask neighbors
      [ set live-neighbors live-neighbors + 1 ] ]
  ;; Starting a new "ask" here ensures that all the cells
  ;; finish executing the first ask before any of them start executing
  ;; the second ask.
  ;; Here we handle the death rule.
  ask cells
    [ ifelse live-neighbors = 2 or live-neighbors = 3
      [ set color white ]
      [ set color gray ] ] ;; gray cells will die next round
                           ;; Now we handle the birth rule.
  ask patches
    [ if not any? cells-here and live-neighbors = 3
      [ birth ]
    ;; While we're doing "ask patches", we might as well
    ;; reset the live-neighbors counts for the next generation.
    set live-neighbors 0 ]
  tick
end 

;; user adds or removes cells with the mouse

to draw-cells
  let erasing? any? cells-on patch mouse-xcor mouse-ycor
  while [mouse-down?]
    [ ask patch mouse-xcor mouse-ycor
      [ ifelse erasing?
        [ erase ]
        [ draw ] ]
    display ]
end 

;; user adds a cell with the mouse

to draw  ;; patch procedure
  if not any? cells-here
    [ ask turtles-here [ die ]  ;; old cells and babies go away
      sprout-cells 1 [ set color white ]
      update
      ask neighbors [ update ] ]
end 

;; user removes a cell with the mouse

to erase  ;; patch procedure
  ask turtles-here [ die ]
  update
  ask neighbors [ update ]
end 

;; this isn't called from GO.  it's only used for
;; bringing individual patches up to date in response to
;; the user adding or removing cells with the mouse.

to update  ;; patch procedure
  ask babies-here
    [ die ]
  let n count cells-on neighbors
  ifelse any? cells-here
    [ ifelse n = 2 or n = 3
      [ ask cells-here [ set color white ] ]
      [ ask cells-here [ set color gray  ] ] ]
    [ if n = 3
      [ sprout-babies 1
        [ set color lime + 1 ] ] ]
  set live-neighbors 0  ;; reset for next time through "go"
end 


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

There are 10 versions of this model.

Uploaded by When Description Download
Uri Wilensky over 11 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky about 12 years ago Updated version tag Download this version
Uri Wilensky about 12 years ago Updated to version from NetLogo 5.0.3 distribution Download this version
Uri Wilensky almost 13 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Model from NetLogo distribution Download this version
Uri Wilensky over 14 years ago Life Turtle-Based Download this version

Attached files

File Type Description Last updated
Life Turtle-Based.png preview Preview for 'Life Turtle-Based' over 11 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.