while True:
angle = Math.PI / 2 - Math.PI / 16
while angle >= -Math.PI / 2:
targetX = hero.pos.x + 5 * Math.cos(angle)
targetY = hero.pos.y + 5 * Math.sin(angle)
dest = ({'x':targetX,'y':targetY})
# Use isPathClear between your current `pos` and the target.
# If the path is clear, move to the target.
if hero.isPathClear(hero.pos, dest):
hero.move(dest)
# Otherwise, sweep the `angle` clockwise a bit.
angle -= Math.PI / 16