Skip to content

A simple command-line tool that generates gif images and animations from elementary cellular automata

Notifications You must be signed in to change notification settings

Zeyu-Li/cellular-automata

 
 

Repository files navigation

cellular

Rust

cellular is a command-line tool that allows for generation of gif images using elementary cellular automata. (Read more about elementary cellular automata here.) It supports starting automata with random seeds as well as providing initial inputs directly through the command line or from a file.

Rule 18

Use

To generate a static image of a cellular automaton with the single middle cell set to 1 and all other cells set to 0, run the following (of width 200 and rule 18):

⚠️ Requires cellular to be installed

sh ./generate.sh 200 18

Installation

Via cargo

cargo install cellular

From source

Download the latest release tarball and execute the following:

tar -xvzf cellular-x.y.z.tar.gz .
cd cellular
cargo install --path .

Note that x.y.z is the version number of the tarball that you downloaded.

Usage

Run the following to see all available options and flags

cellular --help

Examples

Starting with a random initial bitmap

cellular --width 800 --height 600 --frames 100 --density 0.6 --rule 106 --output hello_cellular.gif

or

cellular -w 800 -h 600 -f 100 -d 0.6 -r 106 -o hello_cellular.gif

All options and their shortcut syntax are shown when the help flag is passed

→ cellular --help
cellular
A simple command-line based cellular automaton animation creator

USAGE:
    cellular [FLAGS] [OPTIONS] --frames <frames> --height <height> --width <width>

FLAGS:
        --help       Prints help information
    -n, --no-prog    disable progress bar
    -V, --version    Prints version information

OPTIONS:
    -b, --bitmap <bitmap>      Input bitmap as string of 1s and 0s
    -d, --density <density>    Probability that each cell in initialized bit vector will be occupied. Should be between
                               0.0 and 1.0 [default: 0.5]
    -f, --frames <frames>      Number of frames in final animation
    -h, --height <height>      Specifies height of output image
    -i, --infile <infile>      path to file containing initial bitmap as string of 1s and 0s
    -o, --output <output>      Specifies output file. Defaults to output_w<width>_h<height>_f<frames>_r<rule>.gif
    -r, --rule <rule>          8 bit unsigned integer which specifies the cellular automaton to simulate [default: 110]
    -w, --width <width>        Specifies width of output image

Starting with input provided as a command-line argument

echo "10010111000111" > file
cellular --bitmap 10010111000111 -h 600 -f 100 -d 0.6 -r 106 -o hello_cellular.gif

Starting with input provided from a file

echo "10010111000111" > file
cellular --infile file -h 600 -f 100 -d 0.6 -r 106 -o hello_cellular.gif

Example output

cellular -b 1100111101110100110100011011111110101111101110111001010110011010010001010011111011101110000011100100 -h 100 -f 200 -r 106

Rule 106 output

About

A simple command-line tool that generates gif images and animations from elementary cellular automata

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 96.4%
  • Makefile 3.0%
  • Shell 0.6%