Optimally Navigating a Piecewise-deterministic World