def chooseStrategy():
enemies = self.findEnemies()
enemy = self.findNearest(enemies)
if self.gold > self.costOf("griffin-rider"):
return "griffin-rider"
# If you can summon a griffin-rider, return "griffin-rider"
elif enemy:
if enemy.type is "fangrider" and self.distanceTo(enemy) < 30:
return "fight-back"
# If there is a fangrider on your side of the mines, return "fight-back"
else:
return "collect-coins"
# Otherwise, return "collect-coins"
def commandAttack():
# Command your griffin riders to attack ogres.
for griffin in self.findByType("griffin-rider"):
if griffin:
enemy = griffin.findNearestEnemy()
if enemy:
self.command(griffin, "attack", enemy)
def pickUpCoin():
# Collect coins
coin = self.findNearest(self.findItems())
if coin:
self.move(coin.pos)
def heroAttack():
# Your hero should attack fang riders that cross the minefield.
enemy = self.findNearest(self.findEnemies())
if enemy and self.distanceTo(enemy) < 30:
self.attack(enemy)
loop:
commandAttack()
strategy = chooseStrategy()
# Call a function, depending on what the current strategy is.
if strategy == "griffin-rider":
self.summon("griffin-rider")
if strategy == "fight-back":
heroAttack()
if strategy == "collect-coins":
pickUpCoin()
What happens when you run the code?
youâre not wearing boots that include the move method. Rookie mistake.
Edit: why are you using self instead of hero?
Last time hero.
was replased with self.
. Iâm not sure, about six months ago or a littl bit more. It was somwhere here on the forum. And now they both are working, but in a few last levels it was given self.
as an example in code hints. So, as for me personally, I use self.
writing code from a blank page and hero.
while copypasting my old functions)
hero
works âfasterâ
What boots do I wear?
Any boots with the move method. Iâd pick whatever ones are the fastest and include it. Your current boots only have moveXY and your code is using move.
?
(like this? or another one)
Any of the other boots but those.
def chooseStrategy():
enemies = hero.findEnemies()
enemy = hero.findNearest(enemies)
if hero.gold > hero.costOf("griffin-rider"):
return "griffin-rider"
# If you can summon a griffin-rider, return "griffin-rider"
elif enemy:
if enemy.type is "fangrider" and hero.distanceTo(enemy) < 30:
return "fight-back"
# If there is a fangrider on your side of the mines, return "fight-back"
else:
return "collect-coins"
# Otherwise, return "collect-coins"
def commandAttack():
# Command your griffin riders to attack ogres.
for griffin in hero.findByType("griffin-rider"):
if griffin:
enemy = griffin.findNearestEnemy()
if enemy:
hero.command(griffin, "attack", enemy)
def pickUpCoin():
# Collect coins
coin = hero.findNearest(hero.findItems())
if coin:
hero.move(coin.pos)
def heroAttack():
# Your hero should attack fang riders that cross the minefield.
enemy = hero.findNearest(hero.findEnemies())
if enemy and hero.distanceTo(enemy) < 30:
hero.attack(enemy)
loop:
commandAttack()
strategy = chooseStrategy()
# Call a function, depending on what the current strategy is.
if strategy == "griffin-rider":
hero.summon("griffin-rider")
if strategy == "fight-back":
heroAttack()
if strategy == "collect-coins":
pickUpCoin()
@MunkeyShynes It got to work but my code still doesnât work the minefield explodes.
I used your code with Tharin and passed the level. No 60 second bonus though. Can you post a screenshot of your equipment?
Equip your wolf pet. He catches arrows and will help you survive a few seconds longer. Also, you are using âfor loopsâ in your code but using Programmaticon 3 for your program book. You need Programmaticon 4 to use for loops. Let me know how those two changes work out and weâll go from there if it still doesnât pass.
I changed the Progammaticon to 4 I accidentally equipped 3 lol
@MunkeyShynes I donât think I have the wolf?
Oh. Are you a subscriber? Also, I see you have the invisibility ring but arenât using it. Try using it to last a while longer after the mines blow up.
I canât tell with the helmet on, which hero are you using?
I will try that.
And iâm using tharin.