# Basin Stampede please help

**URL:** <https://discourse.codecombat.com/t/basin-stampede-please-help/10718>\
**Category:** Uncategorized\
**Created:** [February 26, 2017, 12:59am UTC](https://discourse.codecombat.com/t/basin-stampede-please-help/10718 "2017-02-26T00:59:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![George\_Huchins\_Hun](https://avatars.discourse-cdn.com/v4/letter/g/6de8d8/32.png) [@George\_Huchins\_Hun](https://discourse.codecombat.com/u/George_Huchins_Hun)\
**Post date:** [February 26, 2017, 12:59am UTC](https://discourse.codecombat.com/t/basin-stampede-please-help/10718/1 "2017-02-26T00:59:18Z")

</div>

```python

while True:
    enemy = hero.findNearestEnemy()
    xPos = hero.pos.x + 5
    yPos = 17
    if enemy:
        # Adjust y up or down to get away from yaks.
        if enemy.pos.y > hero.pos.y:
            # If the Yak is above you, subtract 3 from yPos.
            hero.pos - 3
            pass
        elif enemy.pos.y < hero.pos.y:
            # If the Yak is below you, add 3 to yPos.
            hero.pos + 3
            pass
    hero.moveXY(xPos, yPos)

```

my code is this but the yak keep hitting me

---

<div class="post-metadata">

**Author:** ![audashious](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/audashious/32/5961_2.png) [@audashious](https://discourse.codecombat.com/u/audashious)\
**Post date:** [February 26, 2017, 1:40am UTC](https://discourse.codecombat.com/t/basin-stampede-please-help/10718/2 "2017-02-26T01:40:04Z")

</div>

Hi George,

in order to change the value of yPos or xPos, you need to redefine them.  
so, instead of “hero.pos - 3” (which you have on line 9)  
you want: “yPos = yPos - 3”

and on line 13, instead of “hero.pos + 3” you want “xPos = xPos + 3”

---

<div class="post-metadata">

**Author:** ![zubbiez](https://avatars.discourse-cdn.com/v4/letter/z/3d9bf3/32.png) [@zubbiez](https://discourse.codecombat.com/u/zubbiez)\
**Post date:** [December 23, 2018, 10:54pm UTC](https://discourse.codecombat.com/t/basin-stampede-please-help/10718/4 "2018-12-23T22:54:00Z")

</div>

# Keep moving right, but adjust up and down as you go.

while True:  
enemy = hero.findNearestEnemy()  
xPos = hero.pos.x + 5  
yPos = 17  
if enemy:  
# Adjust y up or down to get away from yaks.  
if enemy.pos.y \> hero.pos.y:  
# If the Yak is above you, subtract 3 from yPos.  
xPos = xPos - 3  
yPos = yPos - 3  
pass  
elif enemy.pos.y \< hero.pos.y:  
# If the Yak is below you, add 3 to yPos.  
xPos = xPos + 3  
yPos = yPos + 3  
pass  
hero.moveXY(xPos, yPos)

---

<div class="post-metadata">

**Author:** ![MunkeyShynes](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/munkeyshynes/32/9277_2.png) [@MunkeyShynes](https://discourse.codecombat.com/u/MunkeyShynes)\
**Post date:** [December 23, 2018, 10:59pm UTC](https://discourse.codecombat.com/t/basin-stampede-please-help/10718/5 "2018-12-23T22:59:18Z")

</div>

Please learn to post your code properly so we can see the structure. Help us help you.

> [@\[Essentials\] How To Post/Format Your Code Correctly](https://discourse.codecombat.com/t/essentials-how-to-post-format-your-code-correctly/15521):
>
> Formatting your code before posting code is essential to our community, and if you don’t we might not be able to help frowning Everyone must know how to format ALL of your code properly. It’s really easy and only requires a very small amount of effort. To post your code from the game , use the \</\> button or it won’t format properly. When you click the \</\> button, the following will appear: Please paste ALL …

---

<div class="post-metadata">

**Author:** ![Mike\_Bomber](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/mike_bomber/32/11415_2.png) [@Mike\_Bomber](https://discourse.codecombat.com/u/Mike_Bomber)\
**Post date:** [February 11, 2020, 6:11pm UTC](https://discourse.codecombat.com/t/basin-stampede-please-help/10718/6 "2020-02-11T18:11:44Z")

</div>

I put this code and that send me OK

# Sigue moviéndote a la derecha, pero ajusta hacia arriba y hacia abajo a medida que avanzas.

while True:  
enemy = hero.findNearestEnemy()  
xPos = hero.pos.x + 5  
yPos = 17  
if enemy:  
# Ajusta ‘y’ sube o baja para alejarte de los yaks.  
if enemy.pos.y \> hero.pos.y:  
# Si el Yak está por encima de ti, resta 3 de yPos.  
y = y + -1  
pass  
elif enemy.pos.y \< hero.pos.y:  
# Si el Yak está debajo de ti, agrega 3 a yPos  
y = y - +1  
pass  
hero.moveXY(xPos, yPos)
