An implementation of Conway's Game of Life in Rust using the Bevy engine.
Before you start, make sure you have enough free space on your disk. The use of the Bevy engine departs this from a small "Hello, World!" program, combining that with Rust itself and all the crates that need to be compiled, it will take up over 1 GB of space just for those.
First you need to install the Rust toolchain. You can do this by following the instructions on the official website.
The recommended way to install Rust is using rustup
, which comes down to running the following command in your terminal:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
For compiling Bevy, you need to install the following dependencies on Linux:
Ubuntu/Debian:
sudo apt-get install g++ pkg-config libx11-dev libasound2-dev libudev-dev libxkbcommon-x11-0
Fedora:
sudo dnf install gcc-c++ libX11-devel alsa-lib-devel systemd-devel
If using Wayland, you will also need to install the following:
Ubuntu/Debian:
sudo apt-get install libwayland-dev libxkbcommon-dev
Depending on your graphics card, you may have to install one of the following: vulkan-radeon
, vulkan-intel
, or mesa-vulkan-drivers
Fedora:
sudo dnf install wayland-devel libxkbcommon-devel
Note
If you are using a different distribution, another operating system, or have any other issues with dependencies, please refer to the Bevy setup guide.
After fulfilling the requirements, get the source code by e.g. cloning this repository:
git clone https://github.com/Sanubir/game-of-life-rs
Change the working directory to the project's root:
cd game-of-life-rs
To run the project, simply use Cargo:
cargo run --release
The first run will take some time, as Cargo will download and compile all Bevy dependencies.
After the compilation is done, the window should pop up with the simulation running (the grid is randomized on startup).
In the simulation, you can interact with the cells using the mouse and keyboard. The controls are listed below.
Space
- Pause/Unpause the simulationLeft Click
- Make a cell aliveRight Click
- Kill a cellMiddle Click
- Toggle a cell stateC
- Clear the gridQ
/ESC
- Quit
When playing around and making frequent changes to the code, you can use the --features bevy/dynamic_linking
flag to speed up the rebuild process significantly:
cargo run --features bevy/dynamic_linking
The provided flag will compile bevy
as dynamic library, preventing it from having to be statically linked each time you rebuild your project.
This is a very impactful time decrease when doing frequent changes, but it will increase the initial compilation time.
Warning
It will also increase the compiled crates size to almost 5GB!
This project is licensed under the GPL-3.0 license. See the LICENSE file for more information.