Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cells = "000000000000000000000000000100000000000000000000000000000" # starting generation
- rulenum = 90 # rule number
- newcells = ""
- size = len(cells)
- rule = "{0:08b}".format(rulenum)
- def print01(str): # output function
- str01 = ""
- for n in range(len(str)):
- if str[n] == '1':
- str01 = str01+'@'
- else:
- str01 = str01+' '
- return str01
- for e in range(1, 100): # heart of the automaton
- for i in range(len(cells)):
- kern = cells[i-1] + cells[i] + cells[(i+1)%size]
- #print(i)
- #print(kern)
- kernval = int(kern, 2)
- newcells += rule[kernval]
- cells = newcells
- newcells = ""
- print(print01(cells))
- #for i in range(8):
- # print("{0:03b}".format(i))
- # "{0:08b}".format(x)
- # int(bin(x)[2:])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement