I measure the change in my position compaired to my end goal.
I will start out with a variable called "progress" and set it to 10.
so if i am at x=3, y=3 and i want to go goalx=1, goaly=2,
i calculate the distance to my goal.
then every say 200ms i check the change in my distance.
i add the "progress" toward my goal, then subtract the change in time.
ie.
progress += distancetogoal-olddistancetogoal
progress -= (a value * how much time has passed)
so if you were running up a hill then falling back down, you arn't making progress, so your progress will get lower and lower.
i will then run a "stuck" function based on how many times i have been stuck:
function stuck( how many times)
if stuck=0 then jump
if stuck=1 then strafe
if stuck=2 then reverse up, turn then walk forward
...