I am mostly sure I have a correct code based upon what I have found looking at the discourse. Having said this, something seems to happen when there aren’t any enemies: the soldiers stop doing things and don’t attack new enemies until a new soldier is summoned. This has caused my soldiers to become overwhelmed and I can’t pass the level. Is this a bug, or have I just done poorly designing my code to organize the soldiers?
# Gather coins to summon soldiers and have them attack the enemy. while True: # Move to the nearest coin. # Use move instead of moveXY so you can command constantly. coin = hero.findNearestItem() if coin: 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 soldier = soldiers[soldierIndex] # Loop over all your soldiers and order them to attack. while soldierIndex < len(soldiers): # Use the 'attack' command to make your soldiers attack. #hero.command(soldier, "attack", enemy) soldier = soldiers[soldierIndex] hero.command(soldier, "attack", enemy) soldierIndex += 1