I need assistance with “Thunderhooves” if anyone could help that would be very helpful
here is my code btw
while True:
yak = hero.findNearestEnemy()
if yak:
# If yak.pos.y is greater than hero.pos.y
if yak.pos.y > hero.pos.y:
# buildXY a “fence” 10m below the yak.
hero.buildXY("fence", yak.pos.x, yak.pos.y - 10)
else:
# buildXY a “fence” 10m above the yak.
hero.buildXY("fence", yak.pos.x, yak.pos.y + 10)
pass
else:
# moveXY right 10m towards the oasis.
hero.moveXY(hero.pos.x + 10, hero.pos.y)
pass
while True:
if yak:
# If yak.pos.y is greater than hero.pos.y
if yak.pos.y > hero.pos.y:
# buildXY a “fence” 10m below the yak.
hero.buildXY("fence", yak.pos.x, yak.pos.y - 10)
else:
# buildXY a “fence” 10m above the yak.
hero.buildXY("fence", yak.pos.x, yak.pos.y + 10)
pass
else:
# moveXY right 10m towards the oasis.
hero.moveXY(hero.pos.x + 10, hero.pos.y)
pass
How do you compare an else statement to a while true loop? You cannot. It needs to be paired with an if statement. First, have a while true loop. Then inside of that, find the nearest enemy and define it as yak. then check if the yak exists. If it does, then check if its position y is greater than your hero’s position y. If also that is true then, build a fence 10m below the yak. If the yak is above your hero, then build a fence 10m above the yak. If there is no yak, then move 10m to the right.
while True:
yak = hero.findNearestEnemy()
if yak:
#check if the yak's position y is greater than your hero's position y
#build a fence below
#else, your hero's position y is greater than the yak's position y
#build a fence above
else: #there is no yak
#move right