# Show HN: Conway's Game of Life where every cell is an Erlang actor
I built Conway's Game of Life in Erlang where each cell is an independent actor process. This means a 70x45 grid runs 3,150 concurrent processes, all communicating via message passing to determine their fate each generation.
## Why this is interesting
Most Game of Life implementations use a 2D array with a loop. This one uses the actor model - each cell is literally an independent process that:
- Maintains its own alive/dead state
- Sends its state to its 8 neighbors each tick
- Receives states from neighbors via message passing
- Calculates its next state based on Conway's rules
- No shared memory, no locks, pure message passing
## The implementation
Each cell is a gen_server that knows its neighbors' PIDs. Every generation:
1. All cells broadcast their state to neighbors
2. Each cell waits to receive all 8 neighbor states
3. Cells calculate their next state (birth/survival/death)
4. Grid coordinator signals all cells to evolve simultaneously
The visualization uses wxWidgets (built into Erlang/OTP) to show cells as cyan squares on a dark grid. Includes classic patterns like glider guns that continuously spawn new gliders.
## Cool observations
- The glider gun creates new "actors" (gliders) that then live independently
- Cells that die still exist as processes (just dormant) - they can be reborn
- The system gracefully handles thousands of message exchanges per frame
- Each cell makes its own decisions - truly decentralized
This really showcases Erlang's strengths: massive concurrency, fault tolerance, and the actor model. It's surprisingly satisfying to watch, knowing each pixel is its own little process doing its thing.
I built Conway's Game of Life in Erlang where each cell is an independent actor process. This means a 70x45 grid runs 3,150 concurrent processes, all communicating via message passing to determine their fate each generation.
## Why this is interesting
Most Game of Life implementations use a 2D array with a loop. This one uses the actor model - each cell is literally an independent process that: - Maintains its own alive/dead state - Sends its state to its 8 neighbors each tick - Receives states from neighbors via message passing - Calculates its next state based on Conway's rules - No shared memory, no locks, pure message passing
## The implementation
Each cell is a gen_server that knows its neighbors' PIDs. Every generation: 1. All cells broadcast their state to neighbors 2. Each cell waits to receive all 8 neighbor states 3. Cells calculate their next state (birth/survival/death) 4. Grid coordinator signals all cells to evolve simultaneously
The visualization uses wxWidgets (built into Erlang/OTP) to show cells as cyan squares on a dark grid. Includes classic patterns like glider guns that continuously spawn new gliders.
## Cool observations
- The glider gun creates new "actors" (gliders) that then live independently - Cells that die still exist as processes (just dormant) - they can be reborn - The system gracefully handles thousands of message exchanges per frame - Each cell makes its own decisions - truly decentralized
This really showcases Erlang's strengths: massive concurrency, fault tolerance, and the actor model. It's surprisingly satisfying to watch, knowing each pixel is its own little process doing its thing.
Code: https://github.com/Tortured-Metaphor/Conways-Game-of-Life-in...
To run: `git clone` the repo, then `./life_gui_working.erl` (requires Erlang/OTP)
Would love to hear thoughts on other cellular automata that would benefit from the actor model approach!