Fixed errors with ai.py
Working toward random generation of a program tree.  Currently only generates the first node also fails sometimes.