Changed the AI to run in its own thread.