rbdwllr/automata

An Elementary Cellular Automata library for PHP.

Installs: 29

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/rbdwllr/automata

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

This package is auto-updated.

Last update: 2025-09-23 22:45:01 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