A differentiable homotopy approach for solving polynomial optimization problems and noncooperative games