Hey ambassadors. I am pretty new to CodeCombat. I decided to pick ambassador so that I can help others and learn more at the same time. I am just adding this so that ambassadors can help each other and think of ideas to improve CodeCombat. Good luck with it and hope we can improve CodeCombat.
Hey guys. I am having problems with a level called “Thunderhooves.”
Here was the code I wrote.
yak = self.findNearestEnemy()
self.buildXY(“fence”, yak.pos.x, yak.pos.y - 10)
self.buildXY(“fence”, yak.pos.x, yak.pos.y+10)
else: self.moveXY(self.pos.x + 10, self.pos.y)
It looks logically, but I am actually failing with this code. Tell me some solutions.
Also, I know that the code after the loop has to be ahead of the loop, but I just could not get it to code.
The first buildXY instruction does not a proper if guard. What are you trying to do here?
if .yak.pos.y self.buildXY("fence", yak.pos.x, yak.pos.y - 10)
Format your code by putting three back quotes on an empty line before and after your code.
Oops. I made a mistake. I was suppose to write down
if yak.pos.y<self.pos.y: self.buildXY("fence", yak.pos.x, yak.pos.y -10)
Sorry about that.
You code basically says:
if the yak is bellow me: #yak.pos.y < self.pos.y build a fence bellow the yak #yak.pos.y-10
Yes. That is what I am trying to say. Maybe I did a typo or something.
Yes. I GOT through the level. ThanksAdrianCgw for the help.