[SOLVED] How to beat a boulder woods

# Use isPathClear to move around the randomly positioned boulders.
# Automatic pathfinding doesn't work in Boulder Woods.
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)
        # Use isPathClear between your current `pos` and the target.
        # If the path is clear, move to the target.
        
        # Otherwise, sweep the `angle` clockwise a bit.
        angle -= Math.PI / 16

what to do

Hi @Celia_Weng, could I have the link to the level? Thanks :slight_smile:

Rachel

1 Like

So you just got to move. I don’t see the part were you go somewere.

1 Like

The link would be here: CodeCombat - Coding games to learn Python and JavaScript?

1 Like

This comment is telling you to check with an if-statement, that if the path is clear.
A proper isPathClear function would be
hero.isPathClear (hero.pos, #where you want to end)
In this case, it would be ```hero.isPathClear(hero.pos,{‘x’:targetX, ‘y’:targetY})
If the if statement is true, then move your hero to targetX and targetY
And the rest looks good!
Lydia

I agree with @Lydia_Song . That is what I have for my code, and my is working well.

After you tried Lydia’s advice, it should work.
But next time, try the level out yourself before asking for help, because it doesn’t seem that you’ve tried the level. :slight_smile:

Rachel

I used vectors(probably don’t have that yet). You almost got it, but you just have to add 1 more piece of code.

got it LOLLOLOLOLOLO

I did LOLOLOLOLLOLOLOLOLOl

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.