Its super easy with events. Botgotobrick.
A visible leash.
the leash basicaly tells the bot how far it can wander, and you could just use setbotmovement