Feb-22-2017, 02:25 AM
import random numbers = {'***': 128, '** ': 64, '* *': 32, '* ': 16, ' **': 8, ' * ': 4, ' *': 2, ' ': 1} def box(rule, n = 23, width = 79): last = '' for cell in range(width): if random.random() < 0.5: last += '*' else: last += ' ' for generation in range(n): print(last) last = ' {} '.format(last) next = '' for index in range(len(last) - 2): if rule & numbers[last[index:index + 3]]: next += '*' else: next += ' ' last = next box(30)
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures