# Level: Boulder Woods

**URL:** <https://discourse.codecombat.com/t/level-boulder-woods/2959>\
**Category:** Adventurer\
**Created:** [March 5, 2015, 12:11am UTC](https://discourse.codecombat.com/t/level-boulder-woods/2959 "2015-03-05T00:11:32Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vlevo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vlevo/32/2074_2.png) [@Vlevo](https://discourse.codecombat.com/u/Vlevo)\
**Post date:** [March 5, 2015, 12:11am UTC](https://discourse.codecombat.com/t/level-boulder-woods/2959/1 "2015-03-05T00:11:32Z")

</div>

It seems like this level doesn’t have enough explanation or ???

I do what it says I am to do (add an “if”, a “move”, and a “else:”) and my hero runs NE until she gets stuck trying to walk through the forest to the north. (She white-dots along the north edge in the upper alcove.) It looks like once she puts the “go here marker” in the woods she never recovers (never places another).

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/nick/32/784_2.png) [@nick](https://discourse.codecombat.com/u/nick)\
**Post date:** [March 5, 2015, 1:33am UTC](https://discourse.codecombat.com/t/level-boulder-woods/2959/2 "2015-03-05T01:33:23Z")

</div>

Looks like `isPathClear(self, targetPos)` wasn’t working. I had tried to set it up for `isPathClear(self.pos, targetPos)`, but it wasn’t also accepting `self` in place of `self.pos`. It should be good to go now.

---

<div class="post-metadata">

**Author:** ![jklauser](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/jklauser/32/1867_2.png) [@jklauser](https://discourse.codecombat.com/u/jklauser)\
**Post date:** [March 5, 2015, 4:32am UTC](https://discourse.codecombat.com/t/level-boulder-woods/2959/3 "2015-03-05T04:32:49Z")

</div>

It’s working perfectly now.

---

<div class="post-metadata">

**Author:** ![Vlevo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vlevo/32/2074_2.png) [@Vlevo](https://discourse.codecombat.com/u/Vlevo)\
**Post date:** [March 5, 2015, 5:47am UTC](https://discourse.codecombat.com/t/level-boulder-woods/2959/4 "2015-03-05T05:47:10Z")

</div>

Sweet, thanks!! 😃

---

<div class="post-metadata">

**Author:** ![Vettax](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vettax/32/1514_2.png) [@Vettax](https://discourse.codecombat.com/u/Vettax)\
**Post date:** [March 5, 2015, 10:41pm UTC](https://discourse.codecombat.com/t/level-boulder-woods/2959/5 "2015-03-05T22:41:57Z")

</div>

I don’t think it’s a very good example of the move vs moveXY.  
If I well understand the code (not sure), we should be able to do the same with moveXY, as we’re sure the path is clear.  
I tried.  
Problem : the hero can’t reach the target position in some cases. I suppose the isPathClear check the intermediate position are clear, but it seems that it does not ensure that the destination is clear also. The last step is missing.  
 ![](https://sea2.discourse-cdn.com/flex016/uploads/codecombat/2134/2145a222e7ca6395.png)

Appart this trouble, I’m afraid it could mislead people to the real use of move (if I well understand it myself, I just suppose it’s the equivalent of the move in the ancien levels). And also the math stuff could be a fog on the use of the move. Even if it’s a really good example of angle management.

Edit : in the code given at startup, there is some “self” in javascript, instead of “this”.

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/nick/32/784_2.png) [@nick](https://discourse.codecombat.com/u/nick)\
**Post date:** [March 6, 2015, 7:37pm UTC](https://discourse.codecombat.com/t/level-boulder-woods/2959/6 "2015-03-06T19:37:17Z")

</div>

Hmm, it does check both intermediate paths and destination to see if they are clear, but it only has a resolution of 1m. Maybe you’re colliding with an obstacle that doesn’t overlap the target by 1m. This happens with the normal solution?

I fixed the `self`.

---

<div class="post-metadata">

**Author:** ![Vettax](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vettax/32/1514_2.png) [@Vettax](https://discourse.codecombat.com/u/Vettax)\
**Post date:** [March 6, 2015, 8:45pm UTC](https://discourse.codecombat.com/t/level-boulder-woods/2959/7 "2015-03-06T20:45:23Z")

</div>

I don’t know what’s the behavior of move with a collision. With moveXY, it says it can’t get there, but not with move.  
With this code with move, you never really reach the target, so I don’t really know.

---

<div class="post-metadata">

**Author:** ![Arash](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@Arash](https://discourse.codecombat.com/u/Arash)\
**Post date:** [March 7, 2015, 2:56am UTC](https://discourse.codecombat.com/t/level-boulder-woods/2959/8 "2015-03-07T02:56:39Z")

</div>

in level Slalom the isPathClear methods does not identify bear trap and always be the “true”.

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/nick/32/784_2.png) [@nick](https://discourse.codecombat.com/u/nick)\
**Post date:** [March 7, 2015, 4:46am UTC](https://discourse.codecombat.com/t/level-boulder-woods/2959/9 "2015-03-07T04:46:16Z")

</div>

Ah, right; I haven’t hooked it up to know about hazards as trap yet (and `findHazards` doesn’t work yet, either). I’ll get it hooked up for next week’s levels.

---

<div class="post-metadata">

**Author:** ![Oscha](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/oscha/32/2258_2.png) [@Oscha](https://discourse.codecombat.com/u/Oscha)\
**Post date:** [April 4, 2015, 6:01am UTC](https://discourse.codecombat.com/t/level-boulder-woods/2959/10 "2015-04-04T06:01:46Z")

</div>

Hmmm…

Also unclear on how to use the tools to achieve the objective.

I’m not clear how to “sweet the angle” in Cartesian coordinates.

---

<div class="post-metadata">

**Author:** ![HeadMan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/headman/32/6637_2.png) [@HeadMan](https://discourse.codecombat.com/u/HeadMan)\
**Post date:** [July 12, 2015, 6:06pm UTC](https://discourse.codecombat.com/t/level-boulder-woods/2959/11 "2015-07-12T18:06:01Z")

</div>

I would agree with there not being enough explanation (or I’m more dense then most).  
As you can see I have tried different combinations of code that have resulted in either no movement or an error. I guess what the different code really shows is that I have no idea what I’m doing or supposed to be doing. Any help is appreciated and some explanation/clarification would be even more helpful. Thanks

```python
# Use isPathClear to move around the randomly positioned boulders.
# Automatic pathfinding doesn't work in Boulder Woods.

# Runs out of time, hero never moves
target = ({'x': 76, 'y': 34})

# target not defined, line 7 highlighted red
# target.pos = ({'x': 76, 'y': 34})

# line 15 "Math.sin(angle)" highlighted in Green, line 18 'target' highlighted red - target not defined
# targetPos = ({'x': 76, 'y': 34})

loop:
    angle = Math.PI / 2 - Math.PI / 16
    while angle >= -Math.PI / 2:
        targetX = self.pos.x + 5 * Math.cos(angle)
        targetY = self.pos.y + 5 * Math.sin(angle)
        # Use isPathClear between your current pos and the target.
        # If the path is clear, move to the target.
  
        # nothing happens, hero never moves
        if self.isPathClear(self, target):
        
        # isPathClear target not defined - target.pos highlighted green when using line 5
        # line 8 error: target not defined
        # if self.isPathClear(self.pos, target.pos):
        
        # hard excecution limit exceeded
	# if self.isPathClear(self.pos, target.pos):
		
	# hard excecution limit exceeded - line 15 'Math.PI' highlighted green
	# if self.isPathClear(selfPos, targetPos):
            self.move(target)
	    # self.move(target.pos)
	    # self.move(targetPos)
        # Otherwise, sweep the angle clockwise a bit.
        angle -= Math.PI / 16

```

---

<div class="post-metadata">

**Author:** ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/nick/32/784_2.png) [@nick](https://discourse.codecombat.com/u/nick)\
**Post date:** [July 13, 2015, 6:16pm UTC](https://discourse.codecombat.com/t/level-boulder-woods/2959/12 "2015-07-13T18:16:01Z")

</div>

I sent you an email, too, but for any others reading:

The syntax is a bit tricky; there’s more practice with it in the mountain. Here’s one way to do it:

```python
targetX = self.pos.x + 5 * Math.cos(angle)
targetY = self.pos.y + 5 * Math.sin(angle)
target = {"x": targetX, "y": targetY}

```

Then you can use:

```python
if self.isPathClear(self, target):
    self.moveXY(targetX, targetY)

```

---

<div class="post-metadata">

**Author:** ![Scorpioblaze88](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/scorpioblaze88/32/4989_2.png) [@Scorpioblaze88](https://discourse.codecombat.com/u/Scorpioblaze88)\
**Post date:** [January 29, 2017, 5:12pm UTC](https://discourse.codecombat.com/t/level-boulder-woods/2959/13 "2017-01-29T17:12:08Z")

</div>

Or you can just do it the cheap way  
hero.moveXY(23, 44)  
hero.moveXY(49, 40)  
hero.moveXY(71, 47)  
hero.moveXY(76, 46)  
hero.moveXY(76, 34)
