How to resolve the algorithm One-dimensional cellular automata step by step in the Bracmat programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm One-dimensional cellular automata step by step in the Bracmat programming language

Table of Contents

Problem Statement

Assume an array of cells with an initial distribution of live and dead cells, and imaginary cells off the end of the array having fixed values. Cells in the next generation of the array are calculated based on the value of the cell and its left and right nearest neighbours in the current generation. If, in the following table, a live cell is represented by 1 and a dead cell by 0 then to generate the value of the cell at a particular index in the array of cellular values you use the following table:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm One-dimensional cellular automata step by step in the Bracmat programming language

Source code in the bracmat programming language

  ( ( evolve
    =   n z
      .   @( !arg
           : %?n ? @?z
           :   ?
               ( (   ( 000
                     | 001
                     | 010
                     | 100
                     | 111
                     )
                   & 0 !n:?n
                 |   (011|101|110)
                   & 1 !n:?n
                 )
               & ~`
               )
               ?
           )
        | rev$(str$(!z !n))
    )
  & 11101101010101001001:?S
  & :?seen
  &   whl
    ' ( ~(!seen:? !S ?)
      & out$!S
      & !S !seen:?seen
      & evolve$!S:?S
      )
  );

  

You may also check:How to resolve the algorithm Factorial base numbers indexing permutations of a collection step by step in the Perl programming language
You may also check:How to resolve the algorithm Ascending primes step by step in the EasyLang programming language
You may also check:How to resolve the algorithm Halt and catch fire step by step in the XPL0 programming language
You may also check:How to resolve the algorithm Accumulator factory step by step in the Aikido programming language
You may also check:How to resolve the algorithm Create an object at a given address step by step in the Delphi programming language