My hero moves, collects coins and summons soldiers, and my soldiers attack enemies. But my soldiers get overwhelmed by enemies and die. while my hero is left running around collecting coins to eventually die to the enemies.
while True:
coin = self.findNearestItem()
self.move(coin.pos)
if hero.gold > hero.costOf("soldier"):
self.summon("soldier")
enemy = hero.findNearest(hero.findEnemies())
if enemy:
soldiers = hero.findFriends()
soldierIndex = 0
soldier = soldiers[soldierIndex]
while soldierIndex < len(soldiers):
soldier = soldiers[soldierIndex]
hero.command(soldier, "attack", enemy)
soldierIndex +=1