Skip to content

uditvira/Py-Cellular-Automaton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

A simple cellular automaton in Python

How do rules work?

A rule determines how cells evolve over time. Rules are expressed as integers ranging between 0 - 255 (8 bits). The evolution of the cells is easier to understand by looking at the binary representation.

Example:

Let's look at rule 30. In binary this is:

30 = 0b00011110

Now each bit corresonds to a state for three adjacent cells and the value of that bit corresponds to what the next state in the evolution of the center cell is.

Bit         7   6   5   4   3   2   1   0
Previous: 111 110 101 100 011 010 001 000
Rule 30 : [0] [0] [0] [1] [1] [1] [1] [0]

So according to rule 30, 4 possible combinations of cells lead to a 1 in the center cell.

Here's what a single 1 in the centre evolves to over time with rule 30. I've represented 1's with '-' and 0's as ' '

                                                   -
                                                  ---
                                                 --  -
                                                -- ----
                                               --  -   -
                                              -- ---- ---
                                             --  -    -  -
                                            -- ----  ------
                                           --  -   ---     -
                                          -- ---- --  -   ---
                                         --  -    - ---- --  -
                                        -- ----  -- -    - ----
                                       --  -   ---  --  -- -   -
                                      -- ---- --  --- ---  -- ---
                                     --  -    - ---   -  ---  -  -
                                    -- ----  -- -  - -----  -------
                                   --  -   ---  ---- -    ---      -
                                  -- ---- --  ---    --  --  -    ---
                                 --  -    - ---  -  -- --- ----  --  -
                                -- ----  -- -  ------  -   -   --- ----
                               --  -   ---  ----     ---- --- --   -   -
                              -- ---- --  ---   -   --    -   - - --- ---
                             --  -    - ---  - --- -- -  --- -- - -   -  -
                            -- ----  -- -  --- -   -  ----   -  - -- ------
                           --  -   ---  ----   -- -----   - ----- -  -     -
                          -- ---- --  ---   - --  -    - -- -     -----   ---
                         --  -    - ---  - -- - ----  -- -  --   --    - --  -
                        -- ----  -- -  --- -  - -   ---  ---- - -- -  -- - ----
                       --  -   ---  ----   ---- -- --  ---    - -  ----  - -   -
                      -- ---- --  ---   - --    -  - ---  -  -- ----   --- -- ---
                     --  -    - ---  - -- - -  ----- -  ------  -   - --   -  -  -
                    -- ----  -- -  --- -  - ----     ----     ---- -- - - ---------
                   --  -   ---  ----   ---- -   -   --   -   --    -  - - -        -
                  -- ---- --  ---   - --    -- --- -- - --- -- -  ----- - --      ---
                 --  -    - ---  - -- - -  --  -   -  - -   -  ----     - - -    --  -
                -- ----  -- -  --- -  - ---- ---- ----- -- -----   -   -- - --  -- ----
               --  -   ---  ----   ---- -    -    -     -  -    - --- --  - - ---  -   -
              -- ---- --  ---   - --    --  ---  ---   ------  -- -   - --- - -  ---- ---
             --  -    - ---  - -- - -  -- ---  ---  - --     ---  -- -- -   - ----    -  -
            -- ----  -- -  --- -  - ----  -  ---  --- - -   --  ---  -  -- -- -   -  ------
           --  -   ---  ----   ---- -   ------  ---   - -- -- ---  ------  -  -- -----     -

About

Demo code for a cellular automaton in python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages