Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

A (one dimensional) cellular automaton is a function1 F : Σ → Σ with the property that there is a K > 0 such that F (x)i depends only on the 2K + 1 coordinates xi−K , xi−K+1, . . . , xi−1, xi, xi+1, . . . , xi+K . A periodic point of σ is any x such that σ^p (x) = x for some p ∈ N, and a periodic point of F is any x such that F^q (x) = x for some q ∈ N. Given a cellular automaton F, a point x ∈ Σ is jointly periodic if there are p, q ∈ N such that σ^p (x) = F^q (x) = x, that is, it is a periodic point under both functions.

This project aims to explore the nature of one-dimensional Cellular Automata, in the hope of finding the structure of cellular automata through its periodic points.

2034 views
License: MIT
ubuntu2004
1
import argparse
2
from InitialConditions import MiddleStateIsOne, RandomState, FarRightIsOne
3
from Rules import simple_rule, apply_elementary_rule, rule_110
4
from Automata import Automata
5
6
def main():
7
args, initial_condition = parse_args()
8
# Always multiply the number of evolutions by 2 to get the length of each row.
9
# This produces cleaner images.
10
automata = Automata(initial_condition(args.evolutions * 2), apply_elementary_rule(args.rule_number))
11
automata.evolve(len(automata.state))
12
13
def parse_args():
14
parser = argparse.ArgumentParser(description="Build elementary cellular automata.")
15
parser.add_argument('-e', '--evolutions', default=16, type=int, help="The number of evolutions for the CA.")
16
parser.add_argument('-r', '--rule_number', default=30, type=int, help="The rule number for the cellular automata.")
17
parser.add_argument('-s', '--state', default=0, type=int, help="The initial conditions for the first row.\n0: Middle is *. Other cells are -. (default)\n1: Random initial row\n2:Far right is *. (*). Other cells are -.")
18
19
args = parser.parse_args()
20
initial_conditions_map = {
21
0: MiddleStateIsOne,
22
1: RandomState,
23
2: FarRightIsOne
24
}
25
if not args.state in initial_conditions_map.keys():
26
raise ValueError("Input '{}' for state is not valid. Please choose 0, 1 or 2.".format(args.state))
27
28
return args, initial_conditions_map[args.state]
29
30
if __name__ == "__main__":
31
main()
32
33