rust_ca

Crates.iorust_ca
lib.rsrust_ca
version0.2.2
sourcesrc
created_at2022-03-16 10:52:41.551507
updated_at2022-03-31 16:25:24.326348
descriptionA tool for simulating and visualizing cellular automata in Rust
homepage
repositoryhttps://github.com/hugcis/rust_ca
max_upload_size
id551079
size128,470
Hugo Cisneros (hugcis)

documentation

https://docs.rs/rust_ca

README

Rust Cellular Automata

Crates.ioRust

This is a command line tool to simulate and search the space of simple cellular automata (with relatively small neighborhoods).

The tool outputs CA simulations in the form of GIF files.

Install the tool

Run the following command to install on your system:

cargo install rust_ca

To use the library in another Rust project add the following to your Cargo.toml dependencies:

[dependencies]
rust_ca = "0.2.1"

Example

The following command will run a CA with a rule numbered 16855021099980290151. The initial configuration is specified in exploding.pat (by default it is random). The CA has 3 states and is 128x128 cells. We want the output GIF file to represent 2400 time steps, but displaying only 1 in 10.

rust_ca -n 3 -f rules/3_states/16855021099980290151.map.comp \
-p patterns/exploding.pat -k 10 -s 128 --delay 0 -t 2400 

This results in the following test.gif file:

Example CA GIF

Generate random CA GIFs

This generates 200 distinct CA ran for 2400 steps (only showing one in 10) with 4 states.

Warning: This command create 200 GIFs for a total size of ~500MB.

cargo build --release
mkdir rgen
for i in $(seq 0 200); do
rust_ca -n 4 -k 10 -s 128 --delay 0 -t 2400 --rotate 1 --symmetric \
    > rgen/test_$i.gif
done;

CLI

The CLI usage is:

Rust CA 0.2.2
Hugo Cisneros <hmj.cisneros@gmail.com>
A CLI CA simulator. With no options, this runs a randomly sampled CA rule with 2 states for 50 steps
and outputs it as a gif file `test.gif`

USAGE:
    rust_ca [OPTIONS]

OPTIONS:
        --delay <DELAY>
            [default: 10]

    -f, --file <FILE>
            File to read a rule from or write to. The file must contain a valid rule for the
            corresponding number of states

    -h, --help
            Print help information

        --horizon <HORIZON>
            [default: 1]

    -k, --skip <SKIP>
            Steps to skip at every time step for the output [default: 1]

    -n, --states <STATES>
            Number of states of the CA [default: 2]

    -o, --output <OUTPUT>
            A file to write the GIF to. Defaults to standard output

    -p, --pattern <PATTERN>


    -r, --rule <RULE>
            Specify one of the implemented CA rule [possible values: GOL]

        --rotate <ROTATE>
            [default: 0]

        --rule-sampling <RULE_SAMPLING>
            [default: dirichlet] [possible values: uniform, dirichlet]

    -s, --size <SIZE>
            The size of the 2D CA grid [default: 128]

        --symmetric
            Make the rule symmetric (this will also apply to rules passed as files)

    -t, --steps <STEPS>
            Simulation time [default: 50]

        --use-tiled
            Use a tiled CA (defaults to true when the size is a multiple of TILE_SIZE)

    -V, --version
            Print version information

    -w, --write-rule <WRITE_RULE>
            File to read a rule from or write to. The file must contain a valid rule for the
            corresponding number of states
Commit count: 60

cargo fmt