# \[SOLVED\] Oasis, Desert, Python

**URL:** <https://discourse.codecombat.com/t/solved-oasis-desert-python/22596>\
**Category:** Level Help\
**Created:** [June 27, 2020, 11:18pm UTC](https://discourse.codecombat.com/t/solved-oasis-desert-python/22596 "2020-06-27T23:18:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wyattbaek](https://avatars.discourse-cdn.com/v4/letter/w/7c8e57/32.png) [@wyattbaek](https://discourse.codecombat.com/u/wyattbaek)\
**Post date:** [June 27, 2020, 11:18pm UTC](https://discourse.codecombat.com/t/solved-oasis-desert-python/22596/1 "2020-06-27T23:18:49Z")

</div>

I’m using **Hattori** with **856** health. My code is below…

```python
while True:
    enemy = hero.findNearestEnemy()
    if enemy and hero.distanceTo(enemy) < 10:
        x = hero.pos.x - 10
        y = hero.pos.y
    else:
        x = hero.pos.x + 10
        y = hero.pos.y
    hero.moveXY(x, y)

```

At the end, my hero can’t properly dodge the Sand Yak.

![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/c/c8624460ad280a6d58bbe8732ee42140b9e7f3b8.png)

I have used the same code above, and am left with **-25** health.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/b/b543f4d301fdccc819ab6720e739672b80625700.png)

PLEASE HELP!

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [June 27, 2020, 11:36pm UTC](https://discourse.codecombat.com/t/solved-oasis-desert-python/22596/2 "2020-06-27T23:36:38Z")

</div>

You are taking a snapshot view of the hero’s x and y…this is a dynamic, which constantly changes as the hero moves. Instead, try taking a static view.

Your hero.pos.y is not going to change, so there is no need to redefine it after the first time. Instead, try something like this:

while True

```python
define x
define y
if enemy and distance is less than 10, then
    redefine x, decrementing it by 10
oetherwise,
    redefine x, incrementing it by 10
moveXY 

```

---

<div class="post-metadata">

**Author:** ![wyattbaek](https://avatars.discourse-cdn.com/v4/letter/w/7c8e57/32.png) [@wyattbaek](https://discourse.codecombat.com/u/wyattbaek)\
**Post date:** [July 7, 2020, 12:59am UTC](https://discourse.codecombat.com/t/solved-oasis-desert-python/22596/3 "2020-07-07T00:59:45Z")

</div>

The reason was actually because I wasn’t wearing fast enough boots, but thanks for the help!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/a9445509d1a758c41b5ddcddc8c8e20a5dedb67f.png) [@system](https://discourse.codecombat.com/u/system)\
**Post date:** [July 7, 2020, 12:59pm UTC](https://discourse.codecombat.com/t/solved-oasis-desert-python/22596/4 "2020-07-07T12:59:46Z")

</div>

Closed on July 7, 2020, 12:59pm UTC

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