Adding the ai simulation code