I really don’t get what is wrong with my code, please help! Thank you
# 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"
fangrider = hero.findNearest(hero.findByType("fangrider", hero.findEnemies()))
if fangrider and fangrider.pos.x < 37:
return "fight-back"
# Otherwise, return "collect-coins"
else:
return "collect-coins"
def commandAttack():
# Command your griffin riders to attack ogres.
for friend in hero.findFriends():
if friend.type == "griffin-rider":
enemy = friend.findNearestEnemy()
if enemy and enemy.type != "fangrider":
hero.command(friend, "attack", enemy)
pass
def pickUpCoin():
# Collect coins
coin = hero.findNearestItem()
hero.move(coin.pos)
pass
def heroAttack():
# Your hero should attack fang riders that cross the minefield.
enemy = hero.findNearest(hero.findByType("fangrider"))
if enemy.pos.x < 37:
hero.attack(enemy)
pass
while True:
commandAttack()
strategy = chooseStrategy()
# Call a function, depending on what the current strategy is.
if (strategy == "griffin-rider"):
commandAttack()
elif(strategy == "fight-back"):
heroAttack()
else:
pickUpCoin()