# Cellular automata II : Wireworld

Previously : Cellular automatons

## Wire world

Wire world is an automaton designed with the mechanism of electrical wires in mind rather than biological systems. To simulate this, there are four states available :

- Empty space (in black)
- Conductor (in yellow)
- Electron head (in blue)
- Electron tail (in red)

- Empty space never evolves
- Electron heads become electron tails
- Electron tails become conductors
- Conductors remain conductors unless they have exactly one or two neighbours which are electron heads, in which case it becomes an electron head.

A first difference with Conway's game of life is that the structures in Wire World are fairly static : Empty space will always be empty space, while the rest can just be considered a conductor with an extra state added to it. The conductors will serve as tracks for all the behaviours we want to implement.

The implementation isn't too different from the game of life, just replacing the states with 0 for empty space, 1 for conductor, 2 for electron head and 3 for electron tail. The rules are then changed easily enough.

```
function updateGrid()
{
var tmpGrid = [];
for(var i = 0; i < gridSize; i++)
{
switch(grid[i])
{
case 0 :
{
tmpGrid[i] = 0;
break;
}
case 1 :
{
var sum = sumNeighboursTorus(i, 2);
if(sum < 1 && sum > 2)
{
tmpGrid[i] = 1;
}
else
{
tmpGrid[i] = 2;
}
break;
}
case 2 :
{
tmpGrid[i] = 3;
break;
}
case 3 :
{
tmpGrid[i] = 1;
break;
}
}
}
for(var i = 0; i < t; i++)
{
grid[i] = tmpGrid[i];
}
}
```

An immediate consequence of these rules to justify the analogy with wires is that, given a line of conductors, with an electron head paired with an electron tail, this pair will move in the direction of the head.

An important corrolary is that on a branching path, an electron will take both paths, as there's nothing to simulate a drop in voltage!,

Thanks to this quirk, any wire forming a loop will output a signal with some regularity, allowing the construction of a clock.

The clock frequency depends on the perimeter of the loop, as well as the number of electrons circulating in it.

The limit of propagation of electron heads to 1 or 2 neighbouring cells also allows us to stop propagation with the use of 3 conductor cells side by side on a wire.

This allows to construct a diode

## Logic gates

### The OR gate

### The XOR gate

### The AND gate

## Memory

### ROM memory

-Last updated :

*2017-09-22 09:54:56*