Wireworld cellular automaton written in PHP.
Requires PHP 7.4+ and composer.
$ git clone https://github.com/mark-gerarts/wireworld-php.git
$ cd wireworld-php/
$ composer install
$ chmod +x wireworld
$ ./wireworld schemas/repeater.wire
Wireworld rules are explained here. To summarize:
A cell has one of four states. After every step, the cell updates its state according to the following rules:
- Empty → Empty
- Electron head → Electron tail
- Electron tail → Connector
- Connector
- Electron head if exactly one or two neighbouring cells are electron heads
- Remains connector otherwise.
Schemas are simple text files representing the starting state of a Wireworld automaton. It uses following characters:
#
: connectorH
: electron headt
: electron tail
For example, an AND gate:
H##########
###
# # #
H### ### #
# # # # # # #####
# # ### #
# # # ##
#
Take a look at schemas for a list of predefined schemas.
By default, CLI Menu is used to render
the simulation. Use --mode=basic
for a, well, more basic version.
$ ./wireworld schemas/diodes.wire --mode=basic
Starting simulation..
░░
█░░░░░░ ░░░░░
░░
░░
█░░░░░ ░░░░░░
░░
[S]tep / [r]estart / [q]uit:
░░
▒█░░░░░ ░░░░░
░░
░░
▒█░░░░ ░░░░░░
░░
[S]tep / [r]estart / [q]uit:
░░
░▒█░░░░ ░░░░░
░░
░░
░▒█░░░ ░░░░░░
░░
[S]tep / [r]estart / [q]uit: q