Mounatin Mercenaries Error

Your code:

for soldier in soldiers: 
    self.command(soldier, "attack", enemy)

is good but there are a few things missing:

#1 What is the value of soldiers?
#Use a self.findFriends() to give him a value
for soldier in soldiers: 
    #2 How about enemy?
    #Use soldier.findNearestEnemy()
  
   #3 What if enemy does not exists?
    #Use if enemy: 
        self.command(soldier, "attack", enemy)

I changed it to this:

ldiers = self.findFriends()
    soldierIndex += 1
    soldier = soldiers[soldierIndex]
for soldier in soldiers: 
    enemies = soldier.findEnemies()
    enemy = soldier.findNearest(enemies)
    if enemy:
        # Loop over all your soldiers and order them to attack.
        self.command(soldier, "attack", enemy)

But it still doesn’t work. HELP

  1. You ate the beginning of soldiers on the first line
  2. It is strange but for solider in soldiers seem to return dead solider also.
    I put an if solider: to make sure I only command alive ones
soldiers = self.findFriends()
for soldier in soldiers: 
    if soldier:
        enemies = soldier.findEnemies()
        enemy = soldier.findNearest(enemies)
        if enemy:
            # Loop over all your soldiers and order them to attack.
            self.command(soldier, "attack", enemy)

You still need the gathering gold and summoning soldiers parts but I see some code posted earlier.

  1. Get rid of your self.say, each one takes 1 second and they slow you down

The Soldiers still just stand their and I die.

# Gather coins to summon soldiers and have them attack the enemy


loop:
    items = self.findItems()
    item = self.findNearest(items)
    itemPos =  item.pos
    x = itemPos.x
    y = itemPos.y
    # Move to the nearest coin.
    # Use move instead of moveXY so you can command constantly.
    self.moveXY(x, y)
    # If you have funds for a soldier, summon one.
    if self.gold > self.costOf("soldier"):
        self.summon("soldier")
        # Use the 'attack' command to make your soldiers attack.
        #self.command(soldier, "attack", enemy)
soldiers = self.findFriends()
soldier = soldiers[soldierIndex]
for soldier in soldiers: 
    if soldier:
        enemies = soldier.findEnemies()
        enemy = soldier.findNearest(enemies)
        if enemy:
            # Loop over all your soldiers and order them to attack.
            self.command(soldier, "attack", enemy)

this is my code
self.buildXY(“arrow-tower”, self.pos.x, self.pos.y)
loop:
self.shield()
i think this is what is was not supposed to do i just used shield and acted as a meat shield while my arrow-tower killed everything

i kind of cheated i think

How do you get the arrow tower?
Is it level 26?

no i think i leveled up and got it it just popped up as soon a i finished sarvern brawl

I tryed your stretegy but it failed. THe ogres destroyed my arhcer tower the killed me. When I used your code, the ores still killed me.

you move in front of the tower

ya that killed me too

ok so how much health and what shield

Obsidain Engraved Shield and 1369 Health

ok so thats why you lost
i had 2000 health with obsidian shield