Skip to content

8nhuman8/nebular-automata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nebular Automata

The program for visualizing a probabilistic cellular automata

intro_gif

Table of contents

Idea

The original idea was found here, and the author is this person.

Let a square be surrounded on each side by a new square of the same size with a chance of q. Newly formed squares reproduce other squares and so on, to infinity. We will limit the growth of the population by setting a certain maximum allowable number of squares, upon reaching which the program will be completed.

As you probably noticed when looking at the images below, the edges of the shapes have a different color, into which the initial color smoothly flows. This was done not only to illustrate the process of structure development, but also for greater saturation and prettiness of images.

Installation

Install/upgrade required packages with pip install -r requirements.txt --upgrade.

Usage

  1. Check out all the command-line parameters below.
  2. Then you can specify the colors and allowed reproduction directions in the config.json.
  3. Run the renderer.py with python src/renderer.py [parameters you need].

Command-line arguments description

usage: renderer.py [-h] [-sp Y X] [-p FLOAT] [-mc INT] [-minp FLOAT] [-maxp FLOAT] [-rc] [-rbg] [-cn INT] [-s INT] [-o] [-fi] [-t] [-si] [-pi PATH] [-dsi] [-sv]
                   [-pv PATH] [-vfps INT] [-vs INT] [-sg] [-pg PATH] [-gd INT]
                   width height

options:
  -h, --help            show this help message and exit

Required options:
  width                 The width of the image.
  height                The height of the image.

Basic options:
  -sp Y X, --start-point Y X
                        The coordinate of a starting point. Default value: middle of the image.
  -p FLOAT, --probability FLOAT
                        The probability that a square will multiply in a one direction. Default value: 0.51
  -mc INT, --max-count INT
                        The maximum number of squares in the image. Default value: (width * height) // 2.
  -minp FLOAT, --min-percent FLOAT
                        The program will work until the nebula is filled with a chosen or greater percentage.
  -maxp FLOAT, --max-percent FLOAT
                        The program will work until the nebula is filled with a chosen percentage.

Coloring options:
  -rc, --random-colors  All colors will be chosen randomly.
  -rbg, --random-background
                        The background color will be chosen randomly.
  -cn INT, --colors-number INT
                        The number of colors to use in the image. Default value: 3. Use with: -rc.

Additional options:
  -s INT, --seed INT    The program will generate the nebula based on the entered seed. In this case, the generation time is significantly increased.
  -o, --opaque          All colors will be opaque including background.
  -fi, --fade-in        Starting color is white. The color of each new generation will fade into the specified color. Use with: -rc -cn 1
  -t, --torus           The nebula will develop on a grid with toroidal topology.

Image options:
  -si, --save-image     The rendered image will be saved.
  -pi PATH, --path-image PATH
                        The path where the image will be saved. Default path: output/
  -dsi, --dont-show-image
                        Do not show image in the end.

Video options:
  -sv, --save-video     The rendered video will be saved.
  -pv PATH, --path-video PATH
                        The path where the video will be saved. Default path: output/
  -vfps INT, --video-fps INT
                        The frame rate of the video. Default value: 60.
  -vs INT, --video-size INT
                        The size of the video in MB to which the size of the original video will be reduced using compression.

GIF options:
  -sg, --save-gif       The rendered GIF will be saved.
  -pg PATH, --path-gif PATH
                        The path where the GIF will be saved. Default path: output/
  -gd INT, --gif-duration INT
                        The display duration of each frame of the GIF in milliseconds. Default value: 30.

Credits and references

The original idea was found here, and the author is this person.

License

Nebular Automata specific code is distributed under MIT License.

Copyright (c) 2022 Artyom Bezmenov

Gallery

gallery_image_1 gallery_image_2 gallery_image_3 gallery_image_4