A high level analysis of the code spots that the code for the four cases do the exact same thing, just with a minor behavior difference. Specifically, the difference is in how the future position is computed. The remaining code is identical. Isolate the different part and factor out the common part.
As for "no debugger is going to help", that's not true. The debugger allows you to follow the code as it executes and will let you spot the implementation error here. It might take a few hits on the step button, but the error here is clearly debugable.