Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED] Mixed Unit Tactics Python Help

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"]

defendPoints = [{"x": 45, "y": 55},{"x": 45, "y": 45},{"x": 45, "y": 35},{"x": 45, "y": 25}]

def summonTroops():
    type = summonTypes[len(hero.built) % len(summonTypes)]
    if >= hero.costOf(type):

def commandTroops():
    friends = hero.findFriends()
    for i in range(len(friends)):
        friend = friends[i]
        point = defendPoints[i % len(defendPoints)]
        hero.command(friend, "defend", point)

while True:
    friends = hero.findFriends()
    item = hero.findNearestItem()
    if item:

Here is the error:
Screen Shot 2020-02-10 at 2.06.40 PM
Can someone help?

Hi. Command your troops types, not friends)

Thank you! I got it!

You’re welcome)
Good luck)