Adding minimax heuristic function