I have read through the hints (which don’t really help btw) and all of the other topics about this level and i still can’t get my hero to do anything; my hero just stands there doing nothing.
Code
# The goal is to survive for 30 seconds, and keep the mines intact for at least 30 seconds.
def chooseStrategy():
enemies = hero.findEnemies()
# If you can summon a griffin-rider, return "griffin-rider"
if hero.gold >= hero.costOf("griffin-rider"):
return "griffin-rider"
# If there is a fangrider on your side of the mines, return "fight-back"
if enemy.type == "fangrider" and enemy.pos.x <= 36:
return "fight-back"
# Otherwise, return "collect-coins"
else:
return "collect-coins"
def commandAttack():
# Command your griffin riders to attack ogres.
friends = hero.findFriends()
for friend in friends:
hero.command(friend, "attack", enemy)
pass
def pickUpCoin():
# Collect coins
item = hero.findNearestItem()
if item:
hero.moveXY(coin.pos.x, coin.pos.y)
pass
def heroAttack():
# Your hero should attack fang riders that cross the minefield.
hero.attack(enemy)
pass
while True:
strategy = chooseStrategy()
# Call a function, depending on what the current strategy is.
if strategy == 'griffin-rider':
commandAttack()
if strategy == 'fight-back':
heroAttack()
if strategy == 'collect-coins':
pickUpCoin()
# The goal is to survive for 30 seconds, and keep the mines intact for at least 30 seconds.
def chooseStrategy():
enemies = hero.findEnemies()
# If you can summon a griffin-rider, return "griffin-rider"
if hero.gold >= hero.costOf("griffin-rider"):
hero.summon("griffin-rider")
return 'griffin-rider'
# If there is a fangrider on your side of the mines, return "fight-back"
fang = hero.findNearest(hero.findByType("fangrider",enemies))
if fang and fang.pos.x <= 36:
return "fight-back"
# Otherwise, return "collect-coins"
else:
return "collect-coins"
def commandAttack():
# Command your griffin riders to attack ogres.
friends = hero.findFriends()
for friend in friends:
enemy = friend.findNearestEnemy
if enemy:
hero.command(friend, "attack", enemy) #This line here
else:
hero.command(friend, "move", {'x':80,'y':40})
pass
def pickUpCoin():
# Collect coins
item = hero.findNearestItem()
if item:
hero.moveXY(item.pos.x, item.pos.y)
pass
def heroAttack():
fang = hero.findNearest(hero.findByType("fangrider",hero.findEnemies()))
# Your hero should attack fang riders that cross the minefield.
hero.attack(fang)
pass
while True:
strategy = chooseStrategy()
# Call a function, depending on what the current strategy is.
if strategy == 'griffin-rider':
commandAttack()
if strategy == 'fight-back':
heroAttack()
if strategy == 'collect-coins':
pickUpCoin()