Anonymous user
One-dimensional cellular automata: Difference between revisions
One-dimensional cellular automata (view source)
Revision as of 18:12, 10 October 2008
, 15 years ago→{{header|Python}}: Correct for fixed end values, variable length sequence
(→{{header|Python}}: Boolean version) |
(→{{header|Python}}: Correct for fixed end values, variable length sequence) |
||
Line 243:
<python>import random
nquads = 5
maxgenerations = 10
fmt = '%%0%ix'%nquads
#a = int('01110110101010100100', 2)▼
nbits = 4*nquads
a = random.getrandbits(
▲#a = int('01110110101010100100', 2) << 1
endmask = (2<<nbits)-2;
endvals = 0<<(nbits+1) | 0
tr = ('____', '___#', '__#_', '__##', '_#__', '_#_#', '_##_', '_###',
'#___', '#__#', '#_#_', '#_##', '##__', '##_#', '###_', '####' )
for i in range(maxgenerations):
a |= endvals
|