rlife : a cellular automata library written in Rust

In the previous article, I’ve told you I was going to talk more about my personal project, rlife.

So rlife is a life library written in Rust. It aims at allowing to do manipulations on cellular automata, like computing the next generation of a CA, loading/saving a CA from/to a file, do various analysis on it (like locating the coordinates of a pattern, counting the number of living cells) and other manipulations. The main object of this library is the Gridthat represents the grid of the CA and it also stores all its properties (the file format used, the rulesets, the current size of the grid, etc…). This library could allow some developers to use CAs with a high level of abstraction and have the possibility to do many (in the future…) operations on it.

For now, this library is at a very early stage of development so it doesn’t support a lot of things. It supports only 2D life-like CAs and allows only to do basic operations on them (loading/saving in files (with a simple file format used by rlife), computing the next generation, getting/setting the state of a cell in the grid, creating a randomly filled grid of a given size and some more). But of course, it will support other CA types and file formats along with many more operations in the future.

rlife has also two kind of grids. On one hand, you have toroidal grids whose size are fixed but they deal with the edge effect with their toroidal property (i.e. it is as if the left and right borders were connected, as well as the top and bottom ones). On the other hand, you have “resizable” grids whose size will vary accordingly with the size of the pattern contained inside of it: if the pattern grows, the grid will grow and if it shrinks, the grid will shrink too.

I will soon make an evolution that will distinguish rlife with other similar libraries. Instead of doing computations with the CPU, rlife will rely on the GPU for the operations that can profit of its parallelism (and fortunately, most of the essential operations you can do on CAs can benefit from this). And it will use Vulkan via vulkano for this. Maybe Vulkan could also be used to directly render the grid on the screen when needed (if I understand correctly, GTK+ 4 could allow this). The first version of this improvement could land quite soon as I’ve almost finished writing a prototype for this and I will just have to integrate this in rlife.

Finally, I am developing this library in order to use it in a new application. I want to write a cellular automata application for GNOME. I should be able to start its development when rlife will have a minimal Vulkan support and I hope that this application could become something useful.


One thought on “rlife : a cellular automata library written in Rust

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s