Stochastic motion planning and applications to traffic