Thunderhooves help PLZ!


#1

Im stuck on Thunderhooves and cant figure out why its wrong! here’s my code:

while True:
yak = hero.findNearestEnemy()
posy = hero.pos.y
yaky = yak.pos.y - 10
yaky2 = yak.pos.y + 10
if yak:
#A yak is above you if yak.pos.y is greater than your pos.y
if hero.pos.y < yak.pos.y:

        # If the yak is above you, build a fence 10m below it.
        hero.buildXY("fence", posy, yaky)
        # If the yak is below you, build a fence 10m above it.
        hero.buildXY("fence", posy, yaky2)
        pass
else:
    # Move right 10m towards the oasis.
    posy = posy + 10
    pass

#2

First you need to reexamine your build method, because the coordinates you are entering are both y coordinates.

You want to build at the Yak’s x and y-10 position . Also just changing you posy, posy = posy + 10 wont make you actually move.


#3

Thanks! I passed now.:sweat_smile::ok_hand::+1::+1::+1: