Rudimentary AI done.  Lots of refactoring to do.