Well, you could always make it faux-random. As in:
Move Left
Move Down
Move Up
Move Left
Move Down
Move Down
Move Right
Move Up
Move Right
Move Up
That would look random, but ultimately you control it so that it never goes out of bounds and it ends up at the starting point and repeats. You'd probably need to make it longer so that it wouldn't be obvious to the player that it's not actually random.
Alternatively, my Advanced Areas script allows you to confine events within areas:
http://rmrk.net/index.php/topic,25247.0.html.
In that one, you can specify which areas the event can move around in, and it will be prevented from ever venturing outside those boundaries.