completed AI for medium and hard