view ch6ex1.py @ 44:362d4ec7e794

Got a first draft Turing Machine working for chapter 6, exercise 4. Next I have to figure out how to draw it with a TMDrawer class.
author Brian Neal <bgneal@gmail.com>
date Wed, 16 Jan 2013 21:44:02 -0600
parents 49db586c727a
children
line wrap: on
line source
"""Chapter 6, exercise 1 in Allen Downey's Think Complexity book.

"Download thinkcomplex.com/CA.py and thinkcomplex.com/CADrawer.py and confirm
that they run on your system; you might have to install additional Python
packages."

"""
import sys

import CA
from CADrawer import PyplotDrawer

def main(script, rule, n):
    rule = int(rule)
    n = int(n)
    ca = CA.CA(rule, n)
    ca.start_single()
    ca.loop(n - 1)

    drawer = PyplotDrawer()
    drawer.draw(ca)
    drawer.show()


if __name__ == '__main__':
    main(*sys.argv)