Here is my code:
# The goal is to survive for 30 seconds, and keep the mines intact for at least 30 seconds.
enemyIndex = 0
def chooseStrategy():
enemyyyy = hero.findNearestEnemy()
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"
while enemyIndex<len(enemies):
enemy = enemies[enemyIndex]
if enemy.type == 'fangrider' and hero.distanceTo(enemyyyy):
return heroAttack()
enemyIndex+=1
# Otherwise, return "collect-coins"
return pickUpCoin()
def commandAttack():
# Command your griffin riders to attack ogres.
hero.summon("griffin-rider")
enemy = hero.findNearestEnemy()
if enemy:
soldier = hero.findFriends()
soldierIndex = 0
while soldierIndex < len(soldier):
soldier = soldiers[soldierIndex]
hero.command(soldier, "attack", enemy)
soldierIndex+=1
pass
def pickUpCoin():
# Collect coins
item = hero.findNearestItem()
if item:
hero.move(item.pos)
pass
def heroAttack():
# Your hero should attack fang riders that cross the minefield.
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
pass
while True:
commandAttack()
strategy = chooseStrategy()
# Call a function, depending on what the current strategy is.