Implementing Brian’s Brain: A Step-by-Step Guide to Cellular Automata in C
Learn to implement a Cellular Automaton in C. This guide covers Brian's Brain rules, the Moore neighborhood, and a C code walkthrough.

Cellular automata and Moore neighborhood
Cellular automaton (
CA
) is by definition a periodic grid of cells, where in each cell sits a finite automaton, and a set of (identical) rules for every such automaton describing to which state it switches on a next moment of discrete time ti+1, depending of its own state and states of all its neighbors on a current moment of time ti. For now, we will be interested in 2d, rectangular CA, and a neighborhood which includes 8 neighbors of the cell. This is what is called the Moore neighborhood, because it was invented by Edward Moore.
Rules Brain
http://zvold.blogspot.com/2010/01/conways-life-and-brians-brain-cellular.html
- Each cell has three possible states: passive, active, and semi-active.
- If a cell is active, it goes to semi-active state on the next step
- If a cell is semi-active, it becomes passive on the next step
- If a cell is passive, it becomes active if and only if it has exactly 2 active neighbors
Materials
- http://meil.pw.edu.pl/za/ZA/Dydaktyka/Informatyka-1
- https://en.wikipedia.org/wiki/Cellular_automaton
GitHub
git clone git@bitbucket.org:snippets/karol-preiskorn/E8e4L/brians-brain.git
Source
/** * Brian's Brain * * Rules: * ------- * Each cell has three possible states: passive, active, and semi-active. * If a cell is active, it goes to semi-active state on the next step * If a cell is semi-active, it becomes passive on the next step * If a cell is passive, it becomes active if and only if it has exactly 2 active neighbors * **/ #include #include #include #include
Subscribe
Login
0 Comments
Newest
Oldest
Most Voted
Inline Feedbacks
View all comments