I am stuck on Mountain Mercenaries.There are just too many enemy units for my soldiers to handle, and soldiers aren’t attacking until they get attacked. How do I fix my code?
while True: # Move to the nearest coin. # Use move instead of moveXY so you can command constantly. coins = self.findItems() coinIndex = 0 coin = coins[coinIndex] if coin: self.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: # Loop over all your soldiers and order them to attack. soldiers = hero.findFriends() soldierIndex = 0 soldier = soldiers[soldierIndex] # Use the 'attack' command to make your soldiers attack. while soldierIndex < len(soldiers): hero.command(soldier, "attack", enemy) soldierIndex += 1