Coding Challenge:
2D Cellular Automata (Conway’s Game of Life)
using Godot 4.x
Objective
Create an efficient implementation of Conway’s Game of Life cellular automaton that meets the performance requirements below.
See “Background” section at the end to learn about Cellular Automata and the Conway’s Game of Life ruleset.
Challenge Requirements
Core Functionality
- Implement a 2D cellular automata with (at least) the classic Conway’s Game of Life rules (B3S23)
- You can also implement the ability to set custom rules
- Support for wrapping at the grid edges (toroidal grid)
- Fixed grid sizes of at least 256×256 cells
- Include keyboard and/or UI controls for:
- Randomizing the grid before running the simulation (fill 30% of the grid with randomly placed “alive” cells)
- Clearing the grid
- Changing cell size on the fly
- Starting/stopping/pausing/resetting the simulation
Performance Targets
- Must achieve at least 30 FPS with a 256×256 grid, regardless of number of alive or dead cells
- Try to hit at least 30 FPS for larger grid sizes (512×512, 1024×1024, etc…)
- Each render frame should equate to one simulation iteration
- In other words, do not process several iterations before rendering a frame
Display Requirements
- Cell size should be anywhere from 1×1 pixels, to 5×5 pixels (square shaped)
- Alive cells should be green and dead cells should be black
- Bonus for using 3 colors: born=green, alive=orange, dead=black
- Performance metrics should be displayed (FPS, cell counts, generation number, etc.)
- The grid should always be viewable in its entirety (don’t clip the grid)
Notes
- Efficient implementation is key – focus on performance optimization
- You can use any approach or technique available in Godot 4.3
- Consider memory usage, CPU/GPU trade-offs, and data structures
- Documentation of your approach and optimization techniques is encouraged
Evaluation Criteria
- Meeting the performance targets
- Code clarity and organization
- Creative optimization techniques
- Usability of the interface
- Extensibility of the solution
Good luck! This challenge will test your ability to optimize game logic and rendering in Godot while implementing a classic computer science demonstration.
Background / Research
Read about 2D Cellular Automata here:
https://en.wikipedia.org/wiki/Cellular_automaton
Read about the “Conway’s Game of Life rules here:
https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life
Conway’s Game of Life Rules:
- Death: If a cell is alive (state = 1), it will die (state becomes 0) under the following circumstances:
- Overpopulation: If the cell has four or more living neighbors, it dies.
- Loneliness: If the cell has one or fewer living neighbors, it dies.
- Birth: If a cell is dead (state = 0), it will come to life (state becomes 1) when it has exactly three living neighbors (no more, no less).
- Stasis: In all other cases, the cell’s state doesn’t change. Two scenarios are possible:
- Staying alive: If a cell is alive and has exactly two or three live neighbors, it stays alive.
- Staying dead: If a cell is dead and has anything other than three live neighbors, it stays dead.