Implemented first version of AI.