annotate ch6ex1.py @ 47:2b0e229e163c

Chapter 7, exercise 2. R-Pentomino game of life.
author Brian Neal <bgneal@gmail.com>
date Thu, 25 Jul 2013 21:53:44 -0500
parents 49db586c727a
children
rev   line source
bgneal@39 1 """Chapter 6, exercise 1 in Allen Downey's Think Complexity book.
bgneal@39 2
bgneal@39 3 "Download thinkcomplex.com/CA.py and thinkcomplex.com/CADrawer.py and confirm
bgneal@39 4 that they run on your system; you might have to install additional Python
bgneal@39 5 packages."
bgneal@39 6
bgneal@39 7 """
bgneal@39 8 import sys
bgneal@39 9
bgneal@39 10 import CA
bgneal@39 11 from CADrawer import PyplotDrawer
bgneal@39 12
bgneal@39 13 def main(script, rule, n):
bgneal@39 14 rule = int(rule)
bgneal@39 15 n = int(n)
bgneal@39 16 ca = CA.CA(rule, n)
bgneal@39 17 ca.start_single()
bgneal@39 18 ca.loop(n - 1)
bgneal@39 19
bgneal@39 20 drawer = PyplotDrawer()
bgneal@39 21 drawer.draw(ca)
bgneal@39 22 drawer.show()
bgneal@39 23
bgneal@39 24
bgneal@39 25 if __name__ == '__main__':
bgneal@39 26 main(*sys.argv)