refactor to play AI game