Bringing this one up again, I am pretty sure I have the correct code, but I’m posting it here just in case, (gotta look up how to fuzz it out real quick).
My problem is, after the first yak who I successfully block whether it comes from the top or the bottom, my character runs past the second yak, ( whom ALWAYS comes from the bottom no matter how many times I’ve reloaded the page and resubmit) and I head to the bottom of the 2nd yak’s area, where I keep building walls.
To me, it looks like my character is targeting the scorpion, or bones, or something down there that can be identified as an enemy. (I don’t know if they can be or not, I’m just trying to make sense of it) If so, I’ve forgotten how to identify enemies, will targeting the yaks only fix that?
Otherwise, may I get some help as to where my code may be wrong? I’ve also tried elif on the 2nd if, and a few other changes, and I don’t have access to hanzo or other boots right now to try if a different speed will help.
code: (if indents are off, it’s because I screwed them up while putting them in here)
# Get to the oasis,
# fencing off paths with yaks on them as you go.
yak = self.findNearestEnemy()
# A yak is above you if its y is greater than your y.
# If the yak is above you, build a fence 10m below it.
if yak.pos.y > self.distanceTo(yak):
self.buildXY("fence", yak.pos.x, yak.pos.y - 10)
# If the yak is below you, build a fence 10m above it.
if yak.pos.y < self.distanceTo(yak):
self.buildXY("fence", yak.pos.x, yak.pos.y + 10)
# Move right 10m towards the oasis.
self.moveXY(self.pos.x +10, self.pos.y)