Tool for creating and working with Elementary Cellular Automaton.
pip install automatatron
./run.py -r N
Where N
is the rule number. Default rule number is 30.
# Print the first 10 rows of all possible automaton.
for rule in range(1,257):
automaton = automatatron.Engine(rule)
automaton.run(iterations=10)
print automaton
automaton = automatatron.Engine(30)
automaton.run(iterations=50)
print automaton
Prints:
Rule 30, 50 iterations:
#
###
## #
## ####
## # #
## #### ###
## # # #
## #### ######
## # ### #
## #### ## # ###
## # # #### ## #
## #### ## # # ####
## # ### ## ## # #
## #### ## ### ### ## ###
## # # ### # ### # #
## #### ## # # ##### #######
## # ### #### # ### #
## #### ## ### ## ## # ###
## # # ### # ## ### #### ## #
## #### ## # ###### # # ### ####
## # ### #### #### ### ## # #
## #### ## ### # ## # # # ### ###
## # # ### # ### ## # ### ## # # # #
## #### ## # ### # # #### # # ## ######
## # ### #### ## ##### # ##### # # #
## #### ## ### # ## # # ## # ##### ###
## # # ### # ## # #### ## # ## ## # ## #
## #### ## # ### # # # ### #### # ## # ## # ####
## # ### #### #### ## ## ### # # #### # # #
## #### ## ### # ## # # ### # ## #### ### ## ###
## # # ### # ## # # ##### # ###### # # ## # # #
## #### ## # ### # # #### #### #### ## # # #########
## # ### #### #### # # ## # ## # # # # #
## #### ## ### # ## ## ### ## # ### ## # ##### # ## ###
## # # ### # ## # # ## # # # # # #### # # # ## #
## #### ## # ### # # #### #### ##### ## ##### # ## # ## ## ####
## # ### #### #### # # # # # # ### ## # # ### # #
## #### ## ### # ## ## ### ### ###### ## # # ### # # #### ###
## # # ### # ## # # ## ### ### # ## ### ## ## # # #### # #
## #### ## # ### # # #### # ### ### # # ## ### # ## ## # # ######
## # ### #### #### # ###### ### # ## ## ### ###### # ## ##### #
## #### ## ### # ## ## ## ### # ## # # # ### ###### # # ###
## # # ### # ## # # ## # # ## ### # ########## # ## #### ### ## #
## #### ## # ### # # #### ### ## ## ### #### #### ## # ## ### # ####
## # ### #### #### # # # # # # ## # ## # ## ## # ## # ## # #
## #### ## ### # ## ## ### ########### # # ### ## # ##### # # # ### # ## ###
## # # ### # ## # # ## ### # # # # # ## #### ###### # # #### # #
## #### ## # ### # # #### # # ### ## # ##### ## ### # ## # ## ## #######
## # ### #### #### # ###### # # ## # # # # # ##### # ## # # # ## #
## #### ## ### # ## ## ## ##### ## ### ## ######## # ## ## #### # # # ###
## # # ### # ## # # ## # # ## # ## # # # ## ## ## ### ### # # ## ## #
def row_handler(row):
print row
# Run the next 10 iterations, and pass results into specified handler.
automaton.run(handler=row_handler, iterations=10)
automaton = automatatron.Engine(30)
def stream_handler(row, _):
print automatatron.default_string_formatter(row)
time.sleep(0.05)
automaton.run(handler=stream_handler, width=101)
Streams center 101 rows of the automaton continuously to stdout:
###
## #
## ####
## # #
## #### ###
## # # #
## #### ######
## # ### #
## #### ## # ###
## # # #### ## #
## #### ## # # ####
## # ### ## ## # #
## #### ## ### ### ## ###
## # # ### # ### # #
## #### ## # # ##### #######
## # ### #### # ### #
## #### ## ### ## ## # ###
## # # ### # ## ### #### ## #
## #### ## # ###### # # ### ####
## # ### #### #### ### ## # #
## #### ## ### # ## # # # ### ###
## # # ### # ### ## # ### ## # # # #
## #### ## # ### # # #### # # ## ######
## # ### #### ## ##### # ##### # # #
## #### ## ### # ## # # ## # ##### ###
## # # ### # ## # #### ## # ## ## # ## #
## #### ## # ### # # # ### #### # ## # ## # ####
## # ### #### #### ## ## ### # # #### # # #
## #### ## ### # ## # # ### # ## #### ### ## ###
## # # ### # ## # # ##### # ###### # # ## # # #
## #### ## # ### # # #### #### #### ## # # #########
## # ### #### #### # # ## # ## # # # # #
## #### ## ### # ## ## ### ## # ### ## # ##### # ## ###
## # # ### # ## # # ## # # # # # #### # # # ## #
## #### ## # ### # # #### #### ##### ## ##### # ## # ## ## ####
## # ### #### #### # # # # # # ### ## # # ### # #
## #### ## ### # ## ## ### ### ###### ## # # ### # # #### ###
## # # ### # ## # # ## ### ### # ## ### ## ## # # #### # #
## #### ## # ### # # #### # ### ### # # ## ### # ## ## # # ######
## # ### #### #### # ###### ### # ## ## ### ###### # ## ##### #
## #### ## ### # ## ## ## ### # ## # # # ### ###### # # ###
## # # ### # ## # # ## # # ## ### # ########## # ## #### ### ## #
## #### ## # ### # # #### ### ## ## ### #### #### ## # ## ### # ####
## # ### #### #### # # # # # # ## # ## # ## ## # ## # ## # #
## #### ## ### # ## ## ### ########### # # ### ## # ##### # # # ### # ## ###
## # # ### # ## # # ## ### # # # # # ## #### ###### # # #### # #
## #### ## # ### # # #### # # ### ## # ##### ## ### # ## # ## ## #######
## # ### #### #### # ###### # # ## # # # # # ##### # ## # # # ## #
## #### ## ### # ## ## ## ##### ## ### ## ######## # ## ## #### # # # ###
## # # ### # ## # # ## # # ## # ## # # # ## ## ## ### ### # # ## ## #
# #### ## # ### # # #### ### ## ## # ### ## #### ## # # # ## # ## # # # ## # # ### ###
# ### #### #### # # # ### #### # # # # # ## ## # # #### ######## # # # #
#### ## ### # ## ## ### ## # ### # ###### ##### # # # ## ### # # # ### # ## ###
# # ### # ## # # ## ### # #### # ## # ### # # #### # # ## ### ## # # #
## ## # ### # # #### # # ##### ### # ## ## # ## # # #### ## # ### # ## # ## ##### #
### #### #### # ###### # # ## #### # ## #### ## # ## ## # # # #### ## # # # #
## ### # ## ## ## ## ## # # ## # # # # ### # # # ##### #### # ### ##### ##
# ### # ## # # ## # # ## ### # # # # ## ##### ## # #### #### # # ## # # # ##
## # ### # # #### ### ## ## # ### # # #### # ### ## ## # # ### ##### ## ### ## # #
# #### #### # # # ### ###### # # # #### ## ### # # ### ### ## # ### # ### # #
### # ## ## ### ## # # # ## # ## ## ### ### ### #### # # # ### ## ###### ### #
## # ## # # ## ### # ## ### ## # # # # # ## # ### # # ### ## # # ### ### ### #
### # # #### # # ##### # # ## #### #### # # # ##### # ### ## # # # #### # # ## # ##
### #### # ###### # ###### # ### # # # # # ### # # ## ##### # # ###### ## ### #
# ## ## ## ## ## # # # ### ## # # ## ## ## ##### # ## ## # # # ##
# ## # # ## # # ## ### # ## ####### ### # # # ### # ## # #### ## # ## ###### ##
# # # #### ### ## ## # ## ## # ### ### # # # # # #### ## # ## ###### # ## #
#### # # # ### #### ## ### #### ## ### # # ## ## # # ### # ## # # #### # ####
## ## ### ## # # # # # # ## ### # ## # # # # ## ## # # ##### ## ## ##
# # ## ### # ## ### ###### ### ##### # ### # # ####### # # # ## #### # ## # ## ### #
# #### # # ##### # ### # # ###### #### # #### # # # # ##### #### # ##
## # ###### # ###### # ### ### ## # ## ## ## # ##### ##### ### #### ##
## ## ## ## #### ## # ### # ## # # ## # ## # ## # # # ## # ## # ##
## # # ## ### # ## ### # ##### ## ## # #### ## ## #### ## ### ##### ### # # ## #
### ### ## ## # ## ## # ## # # # ## # ### # ### # ### ### # ## ### # # #### ##
# # ### #### ## # # # # ## ## ## # ### # ## ## ### # # ## # # ### # ### ## # ###
# ### ## # # # ###### # # # # ### # # ## ## # ### #### # # ## # # #### ## # ## ## #
### # ## ### ## # # # #### # ### ## ## # ### # # ## # # # # #### # # ##### # ###
# # ##### # ### ## ## # # #### # # ### # #### # # ## # #### # # ## # # ### #
##### # ###### ### # ## # ## ## # ##### # ## ## # #### # # ## ##### # ## ## ###
## ## ### #### ### # ### # ## # ## ## # # ## # ### ## ## # ### # ### # ##
# ## ### # ## # ## # # # # # ## ## # ### #### ## ## # ### #### ## # # # # #
...