CS414 Fall 2017 Program #3
Due: Tuesday, March 7th, 2017.
Before You Begin:
- Create a folder on your computer where your files will be kept.
- To keep your work organized, create a different folder for each
lab, and for each programming assignment.
Cellular Automata
A celluar automaton consists of an array of 1s and 0s, which
is changed with each "generation". The new values form the
next row of the automaton. At each entry, each value in the
new row will depend on the three values above it: one
directly above it, and the other two on either side.
Here is an interesting rule (called "rule 110"):
3 values above |
000 |
001 |
010 |
011 |
100 |
101 |
110 |
111 |
New value below |
1 |
0 |
0 |
1 |
0 |
0 |
0 |
1 |
Let's try out this rule. Suppose the previous row was:
0 0 1 1 0 0 0
Then the next row would be:
0 0 1 0 0 1 0
Notice that we can't use the rule to compute the first and
last values in the next row, because there aren't three
values above it. We set the first and last values
to 0
.
Write a program automaton.py
which does the
following:
- Asks the user for a initial row of values, entered as a
string of 0s and 1s. For example, the user might
type
0011000
.
- Creates a list of
int
s, from the string the
user entered.
- Runs 30 generations of the automaton, using rule 110,
printing each generation as it is computed.