logic for ai moves