A solution to the path planning problem via algebraic geometry and reinforcement learning