#automata #cell #simulator #command-line

bin+lib cell_sim

A 1d cell automata simulator for the command line

6 releases

0.2.1 Jan 25, 2022
0.2.0 Jan 25, 2022
0.1.0 Jan 24, 2022
0.0.3 Jan 22, 2022

#267 in Simulation

MIT license

10KB
175 lines

cellsim

cellsim is a 1d cell automata simulator for the command line, inspired by Stephen Wolfram's elementary celluar automata. Most interesting elementary rules are added with the tool, however new rules can be easily specified using a simple encoding.

Licensed under MIT

Documentation

Screenshot of some results

A screenshot of results from running cellsim

Installation

The binary name for cellsim is in fact cellsim.

The binary for cellsim is currently only available on crates.io, and can be installed via Rust's cargo package manager:

$ cargo install cell_sim

You can also build from source by cloning this repository and building with cargo build.

User Guide

By default, cellsim will calculate the automata using Rule 30. To run the default, the following command can be used:

$ cellsim <iterations> <initial state>

For example, to produce the results from the screenshot above, you'd run:

$ cellsim 10 "           *           "

where in between the quotes spaces represents "dead" cells and asterisks represent "alive" cells.

Further, rules 90, 110, and 184 are also build in. To access these, add the option -r followed by the rule, like so:

cellsim -r rule90 100 "**   * ******   *"

To specify your own rule, you can use the option -c, followed by an encoded version of your rule. The standard format is as follows:

[size of patterns][pattern 1][result][pattern2][result]...

size of patterns is a 4 bit unsigned binary number, which must be odd. A pattern is of the size specified in size of patterns, and consists of 0s and 1s where a 0 represents a dead cell in a pattern and a 1 represents an alive cell. A result is the state of the next cell if the pattern is found, thus uses 0s and 1s as defined above. For example, Rule 30 is defined this way:

# Rule 30 in the standard format

001111101100101010010111010100110000

# annotated
# [0011][111][0][110][0]... and so on

That covers the basics on the program. Be on the lookout for new functionality to be added.

Dependencies

~3MB
~63K SLoC