# Boulder Woods if/else Problem

**URL:** <https://discourse.codecombat.com/t/boulder-woods-if-else-problem/6732>\
**Category:** Solved\
**Created:** [February 9, 2016, 10:58pm UTC](https://discourse.codecombat.com/t/boulder-woods-if-else-problem/6732 "2016-02-09T22:58:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![CodeExpert](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@CodeExpert](https://discourse.codecombat.com/u/CodeExpert)\
**Post date:** [February 9, 2016, 10:58pm UTC](https://discourse.codecombat.com/t/boulder-woods-if-else-problem/6732/1 "2016-02-09T22:58:11Z")

</div>

What is wrong with this code?

# Use isPathClear to move around the randomly positioned boulders.

# Automatic pathfinding doesn’t work in Boulder Woods.

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.  
if self.isPathClear(targetX, targetY):  
self.move({‘x’: targetX, ‘y’: targetY})  
# Otherwise, sweep the angle clockwise a bit.  
angle -= Math.PI / 16  
else:  
self.move({‘x’: targetX, ‘y’: targetY})

It says that there is an “Unexpected Token” on the second-to-last line with the “else:” statement on it. I know that this is a new level so is it me who has done this wrong or developers…? Help please!

---

<div class="post-metadata">

**Author:** ![ChronistGilver](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chronistgilver/32/3778_2.png) [@ChronistGilver](https://discourse.codecombat.com/u/ChronistGilver)\
**Post date:** [February 9, 2016, 11:21pm UTC](https://discourse.codecombat.com/t/boulder-woods-if-else-problem/6732/2 "2016-02-09T23:21:37Z")

</div>

You’re using `isPathClear` wrong. `isPathClear` takes two arguments, the beginning position (in this case, your hero’s position), and the target position.

---

<div class="post-metadata">

**Author:** ![CodeExpert](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@CodeExpert](https://discourse.codecombat.com/u/CodeExpert)\
**Post date:** [February 9, 2016, 11:30pm UTC](https://discourse.codecombat.com/t/boulder-woods-if-else-problem/6732/3 "2016-02-09T23:30:52Z")

</div>

Sooo . . . should I do it more like this?

if self.isPathClear({‘x’: targetX, ‘y’: targetY}, {‘x’: self.pos.x, ‘y’: self.pos.y}):

---

<div class="post-metadata">

**Author:** ![ChronistGilver](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chronistgilver/32/3778_2.png) [@ChronistGilver](https://discourse.codecombat.com/u/ChronistGilver)\
**Post date:** [February 10, 2016, 3:17am UTC](https://discourse.codecombat.com/t/boulder-woods-if-else-problem/6732/4 "2016-02-10T03:17:45Z")

</div>

Yes, more like that, but switch the two arguments.

---

<div class="post-metadata">

**Author:** ![nogard1024](https://avatars.discourse-cdn.com/v4/letter/n/ecc23a/32.png) [@nogard1024](https://discourse.codecombat.com/u/nogard1024)\
**Post date:** [February 10, 2016, 11:16am UTC](https://discourse.codecombat.com/t/boulder-woods-if-else-problem/6732/5 "2016-02-10T11:16:52Z")

</div>

If you’re problem is solved, you can put it in the “solved” category…

---

<div class="post-metadata">

**Author:** ![CodeExpert](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@CodeExpert](https://discourse.codecombat.com/u/CodeExpert)\
**Post date:** [February 10, 2016, 12:59pm UTC](https://discourse.codecombat.com/t/boulder-woods-if-else-problem/6732/6 "2016-02-10T12:59:06Z")

</div>

Cool! Thanks for the help!

---

<div class="post-metadata">

**Author:** ![CodeExpert](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@CodeExpert](https://discourse.codecombat.com/u/CodeExpert)\
**Post date:** [February 10, 2016, 1:00pm UTC](https://discourse.codecombat.com/t/boulder-woods-if-else-problem/6732/7 "2016-02-10T13:00:16Z")

</div>

How do I put it in the “solved” section?

---

<div class="post-metadata">

**Author:** ![UltCombo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ultcombo/32/3822_2.png) [@UltCombo](https://discourse.codecombat.com/u/UltCombo)\
**Post date:** [February 10, 2016, 1:09pm UTC](https://discourse.codecombat.com/t/boulder-woods-if-else-problem/6732/8 "2016-02-10T13:09:15Z")

</div>

I’ve recategorized it for you.  
I’m not sure whether regular users can tag their topics as “solved” on their own.  
You can try clicking the pencil icon at the right of thread title (near the top of this page) and see if you can change the category.
