refactoring the ai class
refactoring the ai class