refactoring minimax with alpha beta pruning