# Level : Oasis not sure if bug or my mistake

**URL:** <https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819>\
**Category:** Bugs\
**Created:** [December 12, 2014, 10:54pm UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819 "2014-12-12T22:54:15Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ReFinig](https://avatars.discourse-cdn.com/v4/letter/r/8e7dd6/32.png) [@ReFinig](https://discourse.codecombat.com/u/ReFinig)\
**Post date:** [December 12, 2014, 10:54pm UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819/1 "2014-12-12T22:54:15Z")

</div>

hi Guys i’m not sure if it’s a bug or i did a mistake so here is my code

```
# Move forward to reach the oasis,
# but move back to avoid nearby yaks.

loop:
    enemy = self.findNearestEnemy()
    if enemy and self.distanceTo(enemy) < 10:
        # Move to the left by subtracting 10 from your X coordinate.
        pass
        x = self.pos.x -10
        y = self.pos.y
        self.moveXY(x, y)

    else:
        x = self.pos.x +10
        y = self.pos.y
        self.moveXY(x, y)
        # Move to the right by addding 10 from your X coordinate.
        pass

```

Do i need to use flags too or i just to focus more  
ps this is the first time getting into trouble lol so please if it’s not a bug don’t post the answer and let me figure it by my self , ty  
Edit : I’m using Tharin

---

<div class="post-metadata">

**Author:** ![Simonster](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@Simonster](https://discourse.codecombat.com/u/Simonster)\
**Post date:** [December 12, 2014, 11:06pm UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819/2 "2014-12-12T23:06:07Z")

</div>

same thing happening to me, the yak at the end gets me no matter what.

---

<div class="post-metadata">

**Author:** ![ReFinig](https://avatars.discourse-cdn.com/v4/letter/r/8e7dd6/32.png) [@ReFinig](https://discourse.codecombat.com/u/ReFinig)\
**Post date:** [December 12, 2014, 11:13pm UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819/3 "2014-12-12T23:13:21Z")

</div>

Maybe we need new Glasses since ours got 5m range ?

---

<div class="post-metadata">

**Author:** ![Simonster](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@Simonster](https://discourse.codecombat.com/u/Simonster)\
**Post date:** [December 12, 2014, 11:23pm UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819/4 "2014-12-12T23:23:20Z")

</div>

ok found the solution. just change the 10 to a 9 in the if enemy and self.distanceTo(enemy) \< 10: . maybe it is just a little bug. idk

---

<div class="post-metadata">

**Author:** ![ReFinig](https://avatars.discourse-cdn.com/v4/letter/r/8e7dd6/32.png) [@ReFinig](https://discourse.codecombat.com/u/ReFinig)\
**Post date:** [December 12, 2014, 11:37pm UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819/5 "2014-12-12T23:37:20Z")

</div>

it’s a bug maybe cause computer starts from 0 and they forgot to code it to start from 1 , i’m not sure , anyway ty

---

<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:** [December 13, 2014, 12:05am UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819/6 "2014-12-13T00:05:45Z")

</div>

I’m pretty confused, because my code is equivalent to yours, but the yaks don’t get me. Can you double-check how much speed you have and let me know? Also, a screenshot of the moment where the yak first gets you would help.

---

<div class="post-metadata">

**Author:** ![sotonin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/sotonin/32/24089_2.png) [@sotonin](https://discourse.codecombat.com/u/sotonin)\
**Post date:** [December 13, 2014, 1:07am UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819/7 "2014-12-13T01:07:34Z")

</div>

i remember that level i had to get creative to beat it. i had the same problem with the yak hitting me. 🙂

I just rechecked it and my speed changed again i guess because it was failing. got it working again for my speed.

```python
// Move forward to reach the oasis,
// but move back to avoid nearby yaks.

loop {
    enemy = this.findNearest(this.findEnemies());
    if (enemy && this.distanceTo(enemy) < 20) {
        // Move to the left by subtracting 10 from your X coordinate.
        x = this.pos.x - 4;
    } else {
        // Move to the right by addding 10 from your X coordinate.
        x = this.pos.x + 4;
    }
    this.moveXY(x, this.pos.y);
}

```

---

<div class="post-metadata">

**Author:** ![ReFinig](https://avatars.discourse-cdn.com/v4/letter/r/8e7dd6/32.png) [@ReFinig](https://discourse.codecombat.com/u/ReFinig)\
**Post date:** [December 13, 2014, 1:18am UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819/8 "2014-12-13T01:18:36Z")

</div>

Here what happend when using \< 10  
 ![](https://sea2.discourse-cdn.com/flex016/uploads/codecombat/1734/2dfee2248d3baf8a.png)

and it worked when used \< 9 ![](https://sea2.discourse-cdn.com/flex016/uploads/codecombat/1735/9c91ce6b70cab435.png)

look like it count 0 as 1 as we alll now computer start from 0 and you didn’t code it to start from 1 , i’m not sure just a guess

---

<div class="post-metadata">

**Author:** ![sotonin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/sotonin/32/24089_2.png) [@sotonin](https://discourse.codecombat.com/u/sotonin)\
**Post date:** [December 13, 2014, 1:20am UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819/9 "2014-12-13T01:20:32Z")

</div>

No. it’s just because everybody has different gear and different speed of movement.

---

<div class="post-metadata">

**Author:** ![ReFinig](https://avatars.discourse-cdn.com/v4/letter/r/8e7dd6/32.png) [@ReFinig](https://discourse.codecombat.com/u/ReFinig)\
**Post date:** [December 13, 2014, 1:21am UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819/10 "2014-12-13T01:21:47Z")

</div>

Maybe you’re right i mentioned in first post that I’m using Tharin as my char

---

<div class="post-metadata">

**Author:** ![sotonin](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/sotonin/32/24089_2.png) [@sotonin](https://discourse.codecombat.com/u/sotonin)\
**Post date:** [December 13, 2014, 1:23am UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819/11 "2014-12-13T01:23:34Z")

</div>

Yep. each hero has a speed but also they can get different boots that further changes that. so this is a pretty tricky level to make work for everybody.

---

<div class="post-metadata">

**Author:** ![jwrobbs](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/jwrobbs/32/1673_2.png) [@jwrobbs](https://discourse.codecombat.com/u/jwrobbs)\
**Post date:** [December 13, 2014, 11:43am UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819/12 "2014-12-13T11:43:04Z")

</div>

I used equivalent code. I made it by going slower. I had a “this.say” attached to every move.

---

<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:** [December 17, 2014, 2:21am UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819/13 "2014-12-17T02:21:19Z")

</div>

I just switched the yak timing a little bit and I think I fixed the problem; please try again with distances of 10 and let me know if you are still seeing any problems. Thanks!

---

<div class="post-metadata">

**Author:** ![calydon](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/calydon/32/1675_2.png) [@calydon](https://discourse.codecombat.com/u/calydon)\
**Post date:** [January 10, 2015, 2:29am UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819/14 "2015-01-10T02:29:08Z")

</div>

I could not figure out what was wrong with my code. Turns out it was just being short-sighted and trying to move too far before checking distance to yaks. I got it working with move distances of 4 and a viewing distance of 20. update: optimal seems to be move dist of 5 and view dist of 10. I’m using Anya with softened leather boots.

It’s the comments that encourage ‘rigid thinking’ with a stated fixed distance of 10. Maybe just sub in ‘a certain distance’ (experiment!) instead of specific measurements?

Also I had to add an extra ‘else’ block because the yaks eventually stop moving and so there are no enemies left to spur movement.

---

<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:** [January 10, 2015, 4:08pm UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819/15 "2015-01-10T16:08:22Z")

</div>

Hmm, it’s supposed to work with `10`m movement. You say that you were trying to move too far–the yaks were getting you before you had time to run, or you ran backwards into a yak…?

---

<div class="post-metadata">

**Author:** ![vvforever](https://avatars.discourse-cdn.com/v4/letter/v/5f9b8f/32.png) [@vvforever](https://discourse.codecombat.com/u/vvforever)\
**Post date:** [January 25, 2015, 8:21am UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819/16 "2015-01-25T08:21:53Z")

</div>

Speed depends on the boots. Try to change boots.  
I passed this level in leather boots

---

<div class="post-metadata">

**Author:** ![gisellie](https://avatars.discourse-cdn.com/v4/letter/g/779978/32.png) [@gisellie](https://discourse.codecombat.com/u/gisellie)\
**Post date:** [February 12, 2015, 4:37pm UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819/17 "2015-02-12T16:37:50Z")

</div>

I did a silly hack…if I used an alert (in the JS version this.say("any message here)) at the beginning of my loop, I survived. Otherwise I died on the first movement. So I “succeeded,” but…meh.

---

<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:** [February 13, 2015, 4:36am UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819/18 "2015-02-13T04:36:50Z")

</div>

Looks like it didn’t quite work for your particular speed, so I tweaked it a bit and it should be working for that speed as well, now, too. Sorry about that!

---

<div class="post-metadata">

**Author:** ![captain\_electro](https://avatars.discourse-cdn.com/v4/letter/c/ecccb3/32.png) [@captain\_electro](https://discourse.codecombat.com/u/captain_electro)\
**Post date:** [March 18, 2015, 11:56pm UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819/19 "2015-03-18T23:56:18Z")

</div>

yeah 10 didn’t work. I had to switch positions ±4 works great.

---

<div class="post-metadata">

**Author:** ![J\_F\_B\_M](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/j_f_b_m/32/2756_2.png) [@J\_F\_B\_M](https://discourse.codecombat.com/u/J_F_B_M)\
**Post date:** [March 19, 2015, 1:37am UTC](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819/21 "2015-03-19T01:37:22Z")

</div>

If you think you found a bug/possible problem, please include all info necessary to solve the issue.

Which hero?  
Which equipment (only boots, ring of speed?, other speed-changing items)?

(Possibly (if extraordinary different): Your code)

[Next page](https://discourse.codecombat.com/t/level-oasis-not-sure-if-bug-or-my-mistake/1819.md?page=2)
