This is my code. I don’t know why it isn’t working.
while True:
coin = hero.findItems()
# Move to the nearest coin.
# Use move instead of moveXY so you can command constantly.
while coin:
coin = hero.findNearestItem()
hero.move(coin.pos)
# If you have funds for a soldier, summon one.
if hero.gold > hero.costOf("soldier"):
hero.summon("soldier")
enemy = hero.findNearest(hero.findEnemies())
if enemy:
soldiers = hero.findFriends()
soldierIndex = 0
while True:
# Loop over all your soldiers and order them to attack.
soldier = soldiers[soldierIndex]
# Use the 'attack' command to make your soldiers attack
hero.command(soldier, "attack", enemy)
#hero.command(soldier, "attack", enemy)