Skip to content

Stepainpy/Any-Cellular-Automata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Any Cellular Automata (ACA)

This program allows you to create cellular automata based on a given world file.

Content

Quick start

Build

mkdir build
cmake -S . -B build
cmake --build build

Launch

As console app

./aca worlds/gol.world

As graphich app (use Raylib)

./aca worlds/gol.world worlds/gui/gol.json

Key map

Key Action
Esc exit from application
Space toggle pause
I toggle viewing count of iterations
B toggle speed
50 FPS <-> 500 FPS
20 ms <-> 2 ms
N step in simulation if set pause

World file syntax

Words, numbers and symbols separated by spacing symbols (space, tab, new line and etc.), Tabulation and line feed it does not matter.
See the other syntax in the EBNF, example file and documentation.

How work may statements

may statement in if block checking via and

'a' may 1 2 3
'b' may 4 5 6
'c' may 7 8 9

as 'a' and 'b' and 'c'

numbers in may statement checking via or
'a' may 1 2 3 as 1 or 2 or 3

Json gui setting

Show example with 'Game of life' gui

{
    "pixel": {
        "width" : 10,
        "height": 10
    },
    "dict": {
        ".": [ 24,  24,  24],
        "#": [231, 231, 231]
    }
}

Where field:

  • pixel contains self size
  • dict contains matched char with color (in RGB)

Colors in dict must be unique because char matched to color and color matched to char

Modifying 'Game of life' rule

Rules for original game maybe present as B3/S23, where B - birth, S - survive

Template:

world 80 30 '.' 2
'.' ; dead
'#' ; live
alias end
rules count
    state '.' to '#' if '#' may
        ; numbers in 'B'
    end
    state '#' to '.' if '#' nomay
        ; numbers in 'S'
    end
end
setup
    ; your setup of world
end

Exapmles: B3/S23, B35678/S5678, B2/S, B3678/S34678
For gui use gol.json

Implemented automata

TODO

  • Add pattern rule
  • Add comments in world file
  • Add alias statement for symbols