Wireworld is fun for the whole family! Your goal is to create a Wireworld implementation in the shortest amount of code possible.
A Wireworld cell can be in one of four different states, usually numbered 0–3 in software, modeled by colors in the examples here:
- Empty (Black)
- Electron head (Blue)
- Electron tail (Red)
- Conductor (Yellow)
As in all cellular automata, time proceeds in ticks. Cells behave as follows:
- Empty → Empty
- Electron head → Electron tail
- Electron tail → Conductor
- Conductor → Electron head if exactly one or two of the neighbouring cells are electron heads, or remains Conductor otherwise.
Your grid must be at least 20 by 20 and must follow the rules of Wireworld. The grid doesn't have to be colored, but make sure it follows these numbers/symbols:
- Empty (0 or ' ')
- Electron head (2 or 'H')
- Electron tail (3 or 'T')
- Conductor (1 or '_')