I had a similar problem on a 3D printer running an all-in-one RAMPS clone (Printrboard F4). The print would go fine for 20 to 50 layers, and then the Y and Z axis would reverse (Or go to absolute value, one direction moves only) and eventually crash the head into the bed. The Gcode was fine. Unfortunately, the only solution was to replace the board. Reflashed several times (You should too!) with no effect.
If your problem is reproducible (Not specific to that one Gcode file) than you might try swapping different parts of your RAMPS set (The arduino, the steppers, the RAMPS shield) until you find out what’s fried. Consider bad cables too, but I would expect problems throughout the print, not at one point…
Good luck! Reflash first!