Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 981bed8

Browse files
Added featured image to last post.
1 parent b66700a commit 981bed8

File tree

1 file changed

+15
-15
lines changed
  • content/posts/elementary-cellular-automata

1 file changed

+15
-15
lines changed

content/posts/elementary-cellular-automata/index.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ categories: ["tutorials"]
77
displayInList: true
88
author: Eitan Lees
99
resources:
10-
- name: CAthumb
10+
- name: featuredImage
1111
src: "ca-thumb.png"
1212
params:
1313
description: "Rule 110"
14-
showOnTop: true
14+
showOnTop: false
1515
---
1616

17-
[Cellular automata](https://en.wikipedia.org/wiki/Cellular_automaton) are discrete models, typically on a grid, which evolve in time. Each grid cell has a finite state, such as 0 or 1, which is updated based on a certain set of rules. A specific cell uses information of the surrounding cells, called it's _neighborhood_, to determine what changes should be made. In general cellular automata can be defined in any number of dimensions. A famous two dimensional example is [Conway's Game of Life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life) in which cells "live" and "die", sometimes producing beautiful patterns.
17+
[Cellular automata](https://en.wikipedia.org/wiki/Cellular_automaton) are discrete models, typically on a grid, which evolve in time. Each grid cell has a finite state, such as 0 or 1, which is updated based on a certain set of rules. A specific cell uses information of the surrounding cells, called it's _neighborhood_, to determine what changes should be made. In general cellular automata can be defined in any number of dimensions. A famous two dimensional example is [Conway's Game of Life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life) in which cells "live" and "die", sometimes producing beautiful patterns.
1818

1919

2020
In this post we will be looking at a one dimensional example known as [elementary cellular automaton](https://en.wikipedia.org/wiki/Elementary_cellular_automaton), popularized by [Stephen Wolfram](https://en.wikipedia.org/wiki/Stephen_Wolfram) in the 1980s.
2121

2222
![](./ca-bar.png)
2323

24-
Imagine a row of cells, arranged side by side, each of which is colored black or white. We label black cells 1 and white cells 0, resulting in an array of bits. As an example lets consider a random array of 20 bits.
24+
Imagine a row of cells, arranged side by side, each of which is colored black or white. We label black cells 1 and white cells 0, resulting in an array of bits. As an example lets consider a random array of 20 bits.
2525

2626

2727
```python
@@ -36,10 +36,10 @@ print(data)
3636
[0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 0 1 1 1 0]
3737

3838

39-
To update the state of our cellular automaton we will need to define a set of rules.
39+
To update the state of our cellular automaton we will need to define a set of rules.
4040
A given cell \\(C\\) only knows about the state of it's left and right neighbors, labeled \\(L\\) and \\(R\\) respectively. We can define a function or rule, \\(f(L, C, R)\\), which maps the cell state to either 0 or 1.
4141

42-
Since our input cells are binary values there are \\(2^3=8\\) possible inputs into the function.
42+
Since our input cells are binary values there are \\(2^3=8\\) possible inputs into the function.
4343

4444

4545
```python
@@ -57,7 +57,7 @@ for i in range(8):
5757
111
5858

5959

60-
For each input triplet, we can assign 0 or 1 to the output. The output of \\(f\\) is the value which will replace the current cell \\(C\\) in the next time step. In total there are \\(2^{2^3} = 2^8 = 256\\) possible rules for updating a cell. Stephen Wolfram introduced a naming convention, now known as the [Wolfram Code](https://en.wikipedia.org/wiki/Wolfram_code), for the update rules in which each rule is represented by an 8 bit binary number.
60+
For each input triplet, we can assign 0 or 1 to the output. The output of \\(f\\) is the value which will replace the current cell \\(C\\) in the next time step. In total there are \\(2^{2^3} = 2^8 = 256\\) possible rules for updating a cell. Stephen Wolfram introduced a naming convention, now known as the [Wolfram Code](https://en.wikipedia.org/wiki/Wolfram_code), for the update rules in which each rule is represented by an 8 bit binary number.
6161

6262
For example "Rule 30" could be constructed by first converting to binary and then building an array for each bit
6363

@@ -91,7 +91,7 @@ for i in range(8):
9191
input:111, index:0, output 0
9292

9393

94-
We can define a function which maps the input cell information with the associated rule index. Essentially we are converting the binary input to decimal and adjusting the index range.
94+
We can define a function which maps the input cell information with the associated rule index. Essentially we are converting the binary input to decimal and adjusting the index range.
9595

9696

9797
```python
@@ -120,8 +120,8 @@ Finally, we can use Numpy to create a data structure containing all the triplets
120120

121121
```python
122122
all_triplets = np.stack([
123-
np.roll(data, 1),
124-
data,
123+
np.roll(data, 1),
124+
data,
125125
np.roll(data, -1)]
126126
)
127127
new_data = rule[np.apply_along_axis(rule_index, 0, all_triplets)]
@@ -131,7 +131,7 @@ print(new_data)
131131
[1 1 1 0 1 1 1 0 1 1 1 0 0 1 1 0 1 0 0 1]
132132

133133

134-
That is the process for a single update of our cellular automata.
134+
That is the process for a single update of our cellular automata.
135135

136136
To do many updates and record the state over time, we will create a function.
137137

@@ -214,9 +214,9 @@ def plot_CA_class(rule_list, class_label):
214214
ax.set_title(f'Rule {rule_list[i]}')
215215
ax.matshow(data)
216216
ax.axis(False)
217-
217+
218218
fig.suptitle(class_label, fontsize=16)
219-
219+
220220
return fig, ax
221221
```
222222

@@ -272,7 +272,7 @@ _ = plot_CA_class([54, 62, 110], 'Class Four')
272272

273273
Amazingly, the interacting structures which emerge from rule 110 has been shown to be capable of [universal computation](https://en.wikipedia.org/wiki/Turing_machine).
274274

275-
In all the examples above a random initial state was used, but another interesting case is when a single 1 is initialized with all other values set to zero.
275+
In all the examples above a random initial state was used, but another interesting case is when a single 1 is initialized with all other values set to zero.
276276

277277

278278
```python
@@ -289,6 +289,6 @@ ax.axis(False);
289289
![png](output_31_0.png)
290290

291291

292-
For certain rules, the emergent structures interact in chaotic and interesting ways.
292+
For certain rules, the emergent structures interact in chaotic and interesting ways.
293293

294294
I hope you enjoyed this brief look into the world of elementary cellular automata, and are inspired to make some pretty pictures of your own.

0 commit comments

Comments
 (0)