while True:
item = hero.findNearestItem()
if item:
hero.move(item.pos)
if hero.gold > hero.costOf("soldier"):
hero.summon("soldier")
enemy = hero.findNearest(hero.findEnemies())
if enemy:
soldiers = hero.findFriends()
soldierIndex = 0
while soldierIndex < soldiers.length:
soldier = soldiers[soldierIndex]
hero.command(soldier, "attack", enemy)
soldierIndex+=1
else:
soldiers = hero.findFriends()
soldierIndex = 0
while soldierIndex < soldiers.length:
soldier = soldiers[soldierIndex]
hero.command(soldier, "move", {"x": 81, "y": 47})
soldierIndex+=1
Read the comments carefully, they want you to use for loops
Ohhhh Thanks, I will try that
This topic might help you with commanding and using for-loops [Solved] How do you command properly