It's easy if you just assume all edges will not have an invisible wall. Just don't walk off them, and you'll be fine.