Help on Mixed Units tactics python

Hi, I need help on Mixed Units tactics in python. Here is my code:

# Practice using modulo to loop over an array

# Choose the mix and order of units you want to summon by populating this array:
summonTypes = ["soldier", "soldier", "soldier", "soldier", "archer", "archer", "archer", "archer"]
def summonTroops():
    # Use % to wrap around the summonTypes array based on len(self.built)
    #type = summonTypes[???]
    type = summonTypes[len(self.built) % len(summonTypes)]
def collectCoins():
    coin = hero.findNearest(hero.findEnemies())
    if coin:
def commandTroops():
    friend = hero.findNearest(hero.findFriends())
    enemy = hero.findNearest(hero.findEnemies())
    if enemy and friend.type is not "palisade":
        if friend:
            hero.command(friend, "attack", enemy)
while True:


In your summonTroops you should be actually summoning a troop.


In your **commandTroops** I don't see a loop iterating through all of the troops to command them to attack. You only command the closest troop.

In your summonTroops you should either do something with the chosen type of unit or return it so that the other part of your code can do something with it.

Your collectCoins has some issues - have a close look at it.