You could keep lists of invisible tracks for your character to follow.
Each track would have its endpoints (x,y pairs).
Restrict your character so that it only travels along just one track.
When it reaches an intersection of two tracks, enable or disable the buttons that would choose its next track and the direction it should travel on that track (towards the other endpoint of that chosen track.)
You would need an extra hidden Arrangement to help you draw the tracks and record them somewhere, maybe as a CSV table in the Media folder.