A high-performance implementation of Conway's Game of Life using the Mojo programming language, featuring interactive visualization with Pygame.
For detailed documentation, including installation guide, usage instructions, and API reference, please visit the documentation website.
- 🚀 High-performance simulation using Mojo
- 📚 Comprehensive documentation with examples
- 🎨 Interactive visualization with Pygame
- ⚡ Optimized grid operations
- 🎮 Interactive controls (pause, step, reset)
- 🎨 Customizable colors and display options
This project is hosted on GitHub: https://github.com/EstRodr/mojo_gol
-
Clone the repository
git clone https://github.com/EstRodr/mojo_gol.git cd mojo_gol
-
View the documentation
- Online: Documentation
- Local: Open
docs/site/index.html
after building the documentation
- 🚀 High-performance simulation using Mojo
- 🎨 Interactive visualization with Pygame
- ⚡ Optimized grid operations
- 🎮 Interactive controls (pause, step, reset)
- 🎨 Customizable colors and display options
- Mojo SDK installed
- Python 3.8+ with Pygame installed
pip install pygame
- Make sure you have the Mojo SDK installed.
To run the Game of Life simulation, use the Mojo interpreter:
# Run the simulation with default settings
mojo life/life.mojo
You can customize the simulation with these arguments:
# Run with custom grid size
mojo life/life.mojo --rows 40 --cols 80
# Run with a specific frame rate
mojo life/life.mojo --fps 10
Space
: Pause/Resume simulationRight Arrow
: Single step when pausedR
: Reset simulationQ
orESC
: Quit+
/-
: Increase/Decrease simulation speed
If you want to build an executable, you can use the Mojo compiler:
mojo build life/life.mojo -o life/game_of_life
Then run it with:
./life/game_of_life
Note: The build step is optional - you can run the script directly with the Mojo interpreter.
You can customize the simulation by modifying the following parameters in life/config.mojo
:
let ROWS = 30 # Number of rows in the grid
let COLS = 50 # Number of columns in the grid
let FPS = 10 # Frames per second
let CELL_SIZE = 20 # Size of each cell in pixels
let ALIVE_COLOR = "#4285F4" # Color of live cells
let DEAD_COLOR = "#202124" # Color of dead cells
mojo-game-of-life/
├── life/
│ ├── life.mojo # Main simulation and visualization
│ ├── gridv1.mojo # Grid implementation
│ ├── pixi.toml # Pixi environment configuration
│ └── pixi.lock # Pixi lock file
├── docs/ # Documentation
├── tests/ # Test files
└── README.md # This file
-
Install Pixi (if not already installed):
curl -fsSL https://pixi.sh/install.sh | bash
-
Install development dependencies:
cd life pixi install
mojo test life/tests/
The implementation is optimized for performance using Mojo's features:
- SIMD operations for grid updates
- Efficient memory management
- Parallel computation where applicable
Contributions are welcome! Please read our Contributing Guidelines for details on how to submit pull requests.
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ and Mojo