Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

📚 The CoCalc Library - books, templates and other resources

132922 views
License: OTHER
1
""" Code example from Complexity and Computation, a book about
2
exploring complexity science with Python. Available free from
3
4
http://greenteapress.com/complexity
5
6
Copyright 2016 Allen Downey
7
MIT License: http://opensource.org/licenses/MIT
8
"""
9
from __future__ import print_function, division
10
11
import sys
12
import matplotlib.pyplot as plt
13
14
from Life import Life, LifeViewer
15
16
17
def main(script, *args):
18
"""Constructs the rabbits methusela.
19
20
http://www.argentum.freeserve.co.uk/lex_r.htm#rabbits
21
"""
22
23
rabbits = [
24
'1000111',
25
'111001',
26
'01'
27
]
28
29
n = 400
30
m = 600
31
life = Life(n, m)
32
life.add_cells(n//2, m//2, *rabbits)
33
viewer = LifeViewer(life)
34
anim = viewer.animate(frames=100, interval=1)
35
plt.subplots_adjust(left=0.01, right=0.99, bottom=0.01, top=0.99)
36
plt.show()
37
38
39
if __name__ == '__main__':
40
main(*sys.argv)
41
42