rbdwllr/automata

An Elementary Cellular Automata library for PHP.

0.0.2-beta.2 2022-01-23 13:44 UTC

This package is auto-updated.

Last update: 2024-04-23 19:00:33 UTC


README

CircleCI SonarCloud SonarCloud

Automata

An Elementary Cellular Automata library for PHP. All credit goes to Stephen Wolfram and Melanie Mitchell.

Basic Usage

use Automata\Automata;

$automata = new Automata();

$result = $automata->generate(110, 4, '01010');

$result->toArray();

Advanced Usage

use Automata\CellsFactory;
use Automata\RulesFactory;
use Automata\Iterator;

$cellsFactory = new CellsFactory();
$cells = $cellsFactory->create("01010");

$rulesFactory = new RulesFactory();
$rules = $rulesFactory->create(110);

$iterator = new Iterator(new Iterate(), $cells, $rules);

$iterations = $iterator->iterate(4);

$iterations->toArray();

Rules

000 = 0
001 = 1
010 = 1
011 = 1
100 = 0
101 = 1
110 = 1
111 = 0