Refactor minimax ai