This page was automatically generated by NetLogo 4.1. Questions, problems? Contact feedback@ccl.northwestern.edu.
The applet requires Java 5 or higher. Java must be enabled in your browser settings. Mac users must have Mac OS X 10.4 or higher. Windows and Linux users may obtain the latest Java from Sun's Java site. If the display appear cut off with Firefox, then try another browser (Safari works).
powered by NetLogo
view/download model file: CA 1D General Totalistic.nlogo
This program is a one-dimensional totalistic cellular automata. In a totalistic CA, the value of the next cell state is determined by the sum of the current cell and its neighbors, not by the values of each individual neighbor. The model allows you to explore the behavior of random totalistic CAs.
This model is intended for the more sophisticated users who are already familiar with basic 1D CA's. If you are exploring CA for the first time, we suggest you first look at one of the simpler CA models such as CA 1D Rule 30.
Each cell may have one of several colors with the values 0 to STATES - 1. The next state of a cell is determined by taking the sum value of the center and the neighbors on each side (as determined by RADIUS). This sum is used as an index into a state-transition table, the "rule," which defines the new state of that cell.
STATES: Defines the number of states of each cell.
RADIUS: Defines the radius on both sides of a cell used to define its
new state.
SET RANDOM SEED: By setting the random seed you can repeat
experiments.
RANDOM RULE: Generates a random transition rule, with all states being
equally likely. The rule is displayed below (RULE CODE, which shows the
new state for each neighborhood total), and its ENTROPY and LAMBDA
parameters are computed.
ENTER RULE: This allows you to enter a rule as a list of state values.
QUIESCENCE: If this is turned on (the usual case), then the quiescent
(0) state will be forced to map into the quiescent state. If it is not
set, then the quiescent state is permitted to map into any state.
DECIMATE: Zeros one of the non-zero entries in the rule, thus causing
that neighborhood sum to map into the quiescent state.
SETUP SINGLE: Sets up a single color-two cell centered in the
top row.
SETUP RANDOM: Sets up cells of uniformly random colors across the top
row.
INPUT INITIAL STATE: Sets up cells of specified state values/colors
near center of top row.
AUTO-CONTINUE?: Automatically continue the CA from the top once it
reaches the bottom row.
GO: Run the CA. If GO is clicked again after a run, the run continues
from the top.
START TEST: Clears the output area, creates a random rule, and
generates a random initial state for a decimation run.
RUN TEST: Equivalent to GO, i.e., runs the CA as above. It is possible
to reset the initial state (e.g., randomly or to specified values) and
RUN TEST again.
CLASSIFY & DECIMATE: Based on the test run, the user types in a
string descibing the behavior (e.g., "IV" or "II (long transient)").
The classification, parameters (lambda etc.), and the rule are written
in the output area. The rule is automatically decimated and the initial
state randomized in preparation for another RUN TEST. At the end of a
decimation run (when the rule is all zeros), the output area can be
copied and pasted into a text file when running under NetLogo (but not
as an applet). Note that you will be alternating between RUN TEST and
CLASSIFY & DECIMATE.
OPEN RECORD-FILE: Open a file to receive the record of a
decimation run (exactly the same information displayed in the output
area, described above). You are requested to enter a filename or path.
Note that you will have to have write access to directory from which
this program is running or to the path. The alternative is to copy and
past from the Output area, as described above.
CLOSE RECORD-FILE: Close the record-file and write it to disk. If you
open a record-file then a previously opened record-file will be closed
automatically. Note, however, that if you quit the program without
closing the record file, you will lose the file's contents!
How does the complexity of the multicolor totalistic CA differ from the two-color CA? (see the CA 1D Elementary model)
Do most rules lead to constantly repeating patterns, nesting, randomness, or more complex behavior (Wolfram Class IV)? What does this tell you about the nature of complexity?
Observe the behavior of a rule under different initial conditions (single point or random initial state). Do different random initial states affect its qualitative behavior.
Start with a random rule and observe its behavior. Then decimate the rule, pick a new random initial state, and observe again. Continue progressively decimating the rule and look for changes in behavior (e.g., different Wolfram classes). Note if qualitative changes of behavior happen at particular values of the LAMBDA or ENTROPY parameters.
Do this decimation experiment with a number of random rules to see if you can determine which parameter best predicts the CAs qualitative behavior.
Explore the effects of different numbers of states and different neighborhood sizes on the CA's qualitative behavior. What conditions seem to be necessary for complex (Class IV) behavior to emerge?
Try making a two-dimensional cellular automaton. The neighborhood could be the eight cells around it, or just the cardinal cells (the cells to the right, left, above, and below).
Life - an example of a two-dimensional cellular automaton
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 250 - the basic rule 250 model
CA 1D Elementary - a simple one-dimensional 2-state cellular automata
model
CA 1D Totalistic - a simple one-dimensional 3-state, unit-radius CA
model
CA Continuous - a totalistic continuous-valued cellular automata with
thousands of states
Thanks to Ethan Bakshy for his help with this model.
The first cellular automaton was conceived by John Von Neumann in the late 1940's for his analysis of machine reproduction under the suggestion of Stanislaw M. Ulam. It was later completed and documented by Arthur W. Burks in the 1960's. Other two-dimensional cellular automata, and particularly the game of "Life," were explored by John Conway in the 1970's. Many others have since researched CA's. In the late 1970's and 1980's Chris Langton, Tom Toffoli and Stephen Wolfram did some notable research. Wolfram classified all 256 one-dimensional two-state single-neighbor cellular automata. In his recent book, "A New Kind of Science," Wolfram presents many examples of cellular automata and argues for their fundamental importance in doing science.
See also:
Von Neumann, J. and Burks, A. W., Eds, 1966. Theory of Self-Reproducing Automata. University of Illinois Press, Champaign, IL.
Toffoli, T. 1977. Computation and construction universality of reversible cellular automata. J. Comput. Syst. Sci. 15, 213-231.
Langton, C. 1984. Self-reproduction in cellular automata. Physica D 10, 134-144
Langton, C. 1990. Computation at the Edge of Chaos: Phase Transitions and Emergent Computation. In Emergent Computation, ed. Stephanie Forrest. North-Holland.
Langton, C. 1992. Life at the Edge of Chaos. In Artificial Life II, ed. Langton et al. Addison-Wesley.
Wolfram, S. 1986. Theory and Applications of Cellular Automata: Including Selected Papers 1983-1986. World Scientific Publishing Co., Inc., River Edge, NJ.
Bar-Yam, Y. 1997. Dynamics of Complex Systems. Perseus Press. Reading, Ma.
Wolfram, S. 2002. A New Kind of Science. Wolfram Media Inc. Champaign, IL.
This model was modified 2007-08-24 by Bruce MacLennan from Uri Wilensky's CA 1D Totalistic model to compute entropy and lambda values, and to allow entering rules and decimation, setting the random seed, specification of initial state, and control and recording of decimation runs. Modified 2008-07-02 for NetLogo 4.0.2.
To refer to the original model in academic publications, please use: Wilensky, U. (2002). NetLogo CA 1D Totalistic model. http://ccl.northwestern.edu/netlogo/models/CA1DTotalistic. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.
In other publications, please use: Copyright 2002 Uri Wilensky. All rights reserved. See http://ccl.northwestern.edu/netlogo/models/CA1DTotalistic for terms of use.
globals [
current-row ;; current row of display
gone? ;; indicates a run has already been completed
state-colors ;; colors corresponding to state values
max-total ;; max total of states of cell and its neighbors
num-rules ;; number of rule entries = max=total + 1
width ;; neighborhood size = 2 * radius + 1
rule ;; transition rule table
non-quiescent-indices ;; list of indices of non-quiescent transitions
config-table ;; table of num of configs for each width and total
pascal-triangle ;; Pascal's triangle for computing binomial coefficients
multiplicity ;; num of configs for a given total
num-virt-rules ;; number of virtual rules (for equiv non-totalistic CA)
lambda ;; Langton lambda of equiv non-totalistic CA
entropy ;; entropy of equiv non-totalistic CA
lambda-T ;; Langton lambda of totalistic CA
entropy-T ;; entropy of totalistic CA
record-file-open? ;; set if record file being created
]
patches-own [value]
to startup
set gone? false
set record-file-open? false
end
;; setup single cell of color-one in the top center row
to setup-single
setup
ask patches with [pycor = current-row]
[ set pcolor item 0 state-colors
set value 0 ]
; set ([value] of patch 0 current-row) 1
ask patch 0 current-row [set value 1]
; set ([pcolor] of patch 0 current-row) item 1 state-colors
ask patch 0 current-row [set pcolor item 1 state-colors]
end
;; setup cells of random distribution across the top row
to setup-random
setup
ask patches with [pycor = current-row]
[ set value random states
set pcolor item value state-colors
]
end
;; setup cells to spcified state colors near center of top row
to setup-specified
setup
ask patches with [pycor = current-row]
[ set pcolor item 0 state-colors
set value 0 ]
let initials read-from-string user-input (word "Enter list of numbers in range 0 to " (states - 1))
if not empty? filter [? >= states or ? < 0] initials
[ output-show (word "Bad states not in range 0 to "
(states - 1) ": " (filter [? >= states or ? < 0] initials))
stop
]
let offset length initials / 2
foreach n-values (length initials) [?]
[ ;set ([value] of patch (? - offset) current-row) item ? initials
;set ([pcolor] of patch (? - offset) current-row) item (item ? initials) state-colors
ask patch (? - offset) current-row
[ set value item ? initials
set pcolor item (item ? initials) state-colors ]
]
end
to setup
set state-colors [ black violet blue green yellow orange red turquoise brown magenta ]
cp ct
set current-row max-pycor ;; set current row to top position
set gone? false
end
to random-full-table ;; compute random transition rule table
set width 2 * radius + 1
set max-total width * (states - 1)
set num-rules max-total + 1
set rule n-values num-rules [ 1 + random (states - 1) ]
set non-quiescent-indices n-values num-rules [?]
if quiescence
[ set rule replace-item 0 rule 0 ;; if quiesence is set, quiescent state remains so
set non-quiescent-indices but-first non-quiescent-indices ]
compute-rule-parameters
end
to specify-rule
set width 2 * radius + 1
set max-total width * (states - 1)
set num-rules max-total + 1
let input-rule read-from-string
user-input (word "Enter list of " num-rules " numbers in range 0 to " (states - 1))
if length input-rule != num-rules or not empty? filter [? >= states or ? < 0] input-rule
[ output-show "Incorrect rule table."
stop
]
set rule input-rule
set non-quiescent-indices filter [item ? rule > 0] (n-values num-rules [?])
compute-rule-parameters
end
to decimate ;; zero (make quiescent) one non-quiescent transition
if empty? non-quiescent-indices [ stop ]
let victim random length non-quiescent-indices
set rule replace-item (item victim non-quiescent-indices) rule 0
set non-quiescent-indices remove-item victim non-quiescent-indices
compute-rule-parameters
end
to compute-rule-parameters ;; compute lambda and entropy parameters for a rule
let quiescent-states length filter [? = 0] rule
set lambda-T 1 - (quiescent-states / num-rules)
let freqs n-values states [ count-total ? ]
;; Either of the following is correct, but the 2nd is more efficient
; set entropy-T 0 - sum map [ plgp (? / num-rules) ] freqs
set entropy-T (log num-rules 2) - (sum map [ plgp ? ] freqs) / num-rules
;; The following computes lambda and entropy for corrsponding
;; "ordinary" (non-totalistic) rule table (the "virtual" rule).
compute-multiplicity-table
set num-virt-rules states ^ width
set quiescent-states sum
map [ ifelse-value ((item ? rule) = 0) [item ? multiplicity] [0] ]
n-values num-rules [?]
set lambda 1 - (quiescent-states / num-virt-rules)
set freqs n-values states [ count-configs-total ? ]
set entropy (log num-virt-rules 2) - (sum map [ plgp ? ] freqs) / num-virt-rules
end
to-report count-total [n] ;; count number of rules leading to state n
report length filter [? = n] rule
end
to-report count-configs-total [n] ;; count number of virtual rules leading to state n
report sum
map [ ifelse-value ((item ? rule) = n) [item ? multiplicity] [0] ]
n-values num-rules [?]
end
to-report plgp [p] ;; compute p lg p correctly if p=0
ifelse p = 0
[ report 0 ]
[ report p * log p 2 ]
end
to compute-multiplicity-table ;; compute table of number of nbd configs for a given total
;; item n (item i config-table) is the number for total n and width i+1
compute-Pascal-triangle (max-total + width - 1)
set config-table (list n-values num-rules [ ifelse-value (? < states) [1] [0] ])
foreach n-values (width - 1) [1 + ?]
[ set config-table lput (config-row ?) config-table ]
set multiplicity item (width - 1) config-table
; set multiplicity n-values num-rules [ configs-for-total ? ]
end
to-report configs-for-total [n]
report (C (width + n - 1) n) -
reduce [?1 + ?2] n-values width
[ (C width (? + 1)) * (C (width + n - (? + 1) * states - 1) (width - 1)) ]
end
to-report config-row [i] ;; compute row i (1..width-1) of config-table
report fput 1 n-values max-total [ configs-for i (? + 1) ]
end
to-report configs-for [i n] ;; compute number of configs of width i+1 for total n
let prev-row item (i - 1) config-table
report ifelse-value (n <= i)
[ C (i + n) n ]
[ sum (ifelse-value (n - states + 1 >= 0)
[ sublist prev-row (n - states + 1) (n + 1) ]
[ sublist prev-row 0 (n + 1) ])
]
end
to-report C [n r] ;; binomial coefficient C (n, r) from Pascal's triangle
ifelse n >= r
[ report item r (item n pascal-triangle) ]
[ report 0 ]
end
to compute-Pascal-triangle [max-n] ;; compute binomial coefficients by Pascal's triangle
; C (n, r) = item r (item n pascal-triangle), for n, r = 0..max-n
set pascal-triangle (list fput 1 n-values max-n [0])
foreach n-values max-n [1 + ?]
[ set pascal-triangle lput (pascal-row ?) pascal-triangle ]
end
to-report pascal-row [n] ;; compute new row of Pascal's triangle from preceding row
let prev-row item (n - 1) pascal-triangle
report fput 1 (map [?1 + ?2] (but-last prev-row) (but-first prev-row))
end
to setup-continue
if not gone? [stop]
let value-list []
set value-list map [[value] of ?] sort patches with [pycor = current-row] ;; copy cell states from the current row to a list
cp ct
set current-row max-pycor ;; reset current row to top
ask patches with [ pycor = current-row ]
[
set value item (pxcor + max-pxcor) value-list ;; copy states from list to top row
set pcolor value-to-color value
]
set gone? false
end
to go
if current-row = min-pycor ;; if we hit the bottom row
[
ifelse auto-continue? ;; continue
[
set gone? true
display ;; ensure full view gets drawn before we clear it
setup-continue
]
[
ifelse gone?
[ setup-continue ] ;; a run has already been completed, so continue with another
[ set gone? true stop ] ;; otherwise stop
]
]
ask patches with [pycor = current-row]
[ do-rule ]
set current-row (current-row - 1)
end
to do-rule ;; patch procedure
let next-patch patch-at 0 -1
let total 0
let mypxcor pxcor
;; set the next state of the cell based on total of neighboring state
; set (value-of next-patch)
; item
; (sum values-from patches with [ pycor = current-row and (abs (pxcor - mypxcor) <= radius) ] [value])
; rule
foreach n-values width [?]
[ set total total + [value] of patch-at (? - radius) 0
]
;set ([value] of next-patch) item total rule
;; paint the next cell based on the new value
;set [pcolor] of next-patch (value-to-color [value] of next-patch)
ask next-patch
[ set value item total rule
set pcolor value-to-color value ]
end
to-report value-to-color [v] ;; convert cell value to color
report item v state-colors
end
to open-record-file
if record-file-open? [ file-close set record-file-open? false ]
file-open user-input "Enter file name or path"
set record-file-open? true
setup-random
end
to close-record-file
if record-file-open? [ file-close ]
set record-file-open? false
end
to classify
let class user-input "Enter class"
if record-file-open?
[ file-write class
file-print (list lambda lambda-T entropy entropy-T rule)
]
output-write class
output-print (list lambda lambda-T entropy entropy-T rule)
decimate
setup-random
end
; Modified 2007-07-30 by Bruce MacLennan from CA 1D Totalistic by Uri Wilensky,
; which bears the following copyright:
;
; *** NetLogo 3.1.4 Model Copyright Notice ***
;
; This model was created as part of the projects:
; PARTICIPATORY SIMULATIONS: NETWORK-BASED DESIGN FOR SYSTEMS LEARNING IN
; CLASSROOMS and/or INTEGRATED SIMULATION AND MODELING ENVIRONMENT.
; The project gratefully acknowledges the support of the
; National Science Foundation (REPP & ROLE programs) --
; grant numbers REC #9814682 and REC-0126227.
;
; Copyright 2002 by Uri Wilensky. All rights reserved.
;
; Permission to use, modify or redistribute this model is hereby granted,
; provided that both of the following requirements are followed:
; a) this copyright notice is included.
; b) this model will not be redistributed for profit without permission
; from Uri Wilensky.
; Contact Uri Wilensky for appropriate licenses for redistribution for
; profit.
;
; To refer to this model in academic publications, please use:
; Wilensky, U. (2002). NetLogo CA 1D Totalistic model.
; http://ccl.northwestern.edu/netlogo/models/CA1DTotalistic.
; Center for Connected Learning and Computer-Based Modeling,
; Northwestern University, Evanston, IL.
;
; In other publications, please use:
; Copyright 2002 Uri Wilensky. All rights reserved.
; See http://ccl.northwestern.edu/netlogo/models/CA1DTotalistic
; for terms of use.
;
; *** End of NetLogo 3.1.4 Model Copyright Notice ***