AI bug fixes

Fixed a couple of bugs in the AI.  It's very basic, but it should be
fully functional now.