Here is the code w/o workaround below. It fails due to timeout. If I uncomment “beamPath()” in the middle, which is nothing but checking path of wider corridor or “beam” to the target then it works because hero gets stuck much less so it can finish on time, typically using more than half duration allowed.

May be something else is wrong, pls advise.

Try using `(target.pos.x, target.pos.y)`

instead of `(target.x, target.y)`

I believe target here is a dictionary that expected to have x,y and not another dict pos (pos.x,pos.y). This is clear also from first arg “hero.pos” and not “hero”.

```
# Use isPathClear to move around the randomly positioned boulders.
# Automatic pathfinding doesn't work in Boulder Woods.
endTarget = {"x": 76, "y": 35}
angle = Math.PI / 2
while True:
targetX = hero.pos.x + 6 * Math.cos(angle)
targetY = hero.pos.y + 6 * Math.sin(angle)
moveX = hero.pos.x + 2 * Math.cos(angle)
moveY = hero.pos.y + 2 * Math.sin(angle)
# Use isPathClear between your current `pos` and the target.
target = {"x": targetX, "y": targetY}
if hero.isPathClear(hero.pos, endTarget):
#first try to reach end Target
hero.moveXY(endTarget.x, endTarget.y)
#elif beamPath(target,2):
elif hero.isPathClear(hero.pos, target):
# If the path is clear, move to the target.
hero.moveXY(target.x, target.y)
angle = -Math.PI / 8
else:
# Otherwise, sweep the `angle` clockwise a bit.
angle += Math.PI / 16
```