An expandable cell class intended for constructing Cellular Automata
Project description
Cell class for Cellular Automata
How to install
pip install cellular-automata-class
How to use
Import the class as:
from cellular_automata_class import cell
It can be used to set up a lattice:
def set_lattice(length, choice):
'''
Given the choice of lattice pattern, sets a 2 dimensional, finite lattice,
digits of which store a cell each
'''
lattice = []
for n in range(length):
lattice.append([])
for x in range(length):
for y in range(length):
lattice[x] += [Cell(1,x,y) if x == math.floor(length/2) else Cell(0,x,y)]
return lattice
In order to "play" the lattice, we need to iterate through the whole lattice calling cell.evaluate()
method:
def play(lattice, evaluation_count):
'''
After main() receives the input and sets the lattice,
play() takes care of the rest. Just to keep main() tiny and neat.
'''
images = []
for n in range(evaluation_count):
lattice_copy = copy.deepcopy(lattice)
for x in lattice:
for y in x:
y.evaluate(lattice_copy)
The class can be expanded in various ways. E.g. we can add stochastic element to it, we can add new neighborhood types, etc.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for cellular_automata_class-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a58162aa0ed6639ac73b9cc39007bd6032d40b9104360f22d06877ff039aee7 |
|
MD5 | b06b8786ba11d05bed039716f140a59b |
|
BLAKE2b-256 | c4159e47eca3bd740da4984ad40aa4dcaef05d7cb8d2d6a13854c13f3229b743 |
Close
Hashes for cellular_automata_class-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bd41e0336f6c892e2f2448501bfa236e2a736f3a34cd1b8ec662186566cd58d |
|
MD5 | c876731dcfcf2f21316592caa24006c9 |
|
BLAKE2b-256 | 16970f24e70861600241253b93be11f37431b42588eb226679085c262dc68ba7 |