# I need help on thunderhooves and my code is not working and I have no reason as to why it is not

**URL:** <https://discourse.codecombat.com/t/i-need-help-on-thunderhooves-and-my-code-is-not-working-and-i-have-no-reason-as-to-why-it-is-not/3173>\
**Category:** Uncategorized\
**Created:** [March 20, 2015, 1:34pm UTC](https://discourse.codecombat.com/t/i-need-help-on-thunderhooves-and-my-code-is-not-working-and-i-have-no-reason-as-to-why-it-is-not/3173 "2015-03-20T13:34:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter517](https://avatars.discourse-cdn.com/v4/letter/p/7cd45c/32.png) [@Peter517](https://discourse.codecombat.com/u/Peter517)\
**Post date:** [March 20, 2015, 1:34pm UTC](https://discourse.codecombat.com/t/i-need-help-on-thunderhooves-and-my-code-is-not-working-and-i-have-no-reason-as-to-why-it-is-not/3173/1 "2015-03-20T13:34:52Z")

</div>

```python
// Get to the oasis,
// fencing off paths with yaks on them as you go.
loop {
    var yak = this.findNearestEnemy();
    if (yak) {
        // A yak is above you if it's y is greater than your y.
        // If the yak is above you, build a fence 10m below it.
        if (this.distanceTo(yak) > y) {
            this.buildXY("fence", x, y + 4);
        }
        // If the yak is below you, build a fence 10m above it.
        if (this.distanceTo(yak) < y) {
            this.buildXY("fence", x, y - 4);
        }
    } else {
        // Move right 10m towards the oasis.
        var x = this.pos.x + 10;
        var y = this.pos.y;
        this.moveXY(x, y);
    }
}

```

---

<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 20, 2015, 3:49pm UTC](https://discourse.codecombat.com/t/i-need-help-on-thunderhooves-and-my-code-is-not-working-and-i-have-no-reason-as-to-why-it-is-not/3173/2 "2015-03-20T15:49:49Z")

</div>

You are using x & y, but where do you set them??  
The directions say “build a fence 10m below/above it.” but I see “±4” not ±10.  
The directions suggest you check where the yak is not how far away.

```python
if (this.distanceTo(yak) < y) {
            this.buildXY("fence", x, y - 4);

```

If you are unsure how to set x & y look at the else clause…  
(Should you build the fence above/below you (this) or the yak (yak)?)
