def chooseStrategy():
enemies = hero.findEnemies()
enemy = hero.findNearest(enemies)
# 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”
elif enemy and enemy.type == “fangrider” and hero.distanceTo(enemy) < 30:
return “fight-back”
# Otherwise, return “collect-coins”
else:
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
while True:
item = hero.findNearestItem()
if item:
hero.move(item.pos)
pass
def heroAttack():
# Your hero should attack fang riders that cross the minefield.
target = hero.findNearest(hero.findByType(“fangrider”))
if target:
if hero.distanceTo(target) < 20:
hero.move(targetPos)
else:
hero.attack(target)
while True:
commandAttack()
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()
if you have a code that works please post it!