Machine learning and dynamic programming algorithms for motion planning and control