Help with steelclaw gap


can some one help with my code

# This level introduces the % operator, also known as the modulo operator.
# a % b returns the remainder of a divided by b
# This can be used to wrap around to the beginning of an array when an index might be greater than the length

defendPoints = [{"x": 35, "y": 63},{"x": 61, "y": 63},{"x": 32, "y": 26},{"x": 64, "y": 26}]

summonTypes = ["soldier","soldier","soldier","soldier","archer","archer","archer","archer"]

# You start with 360 gold to build a mixture of soldiers and archers.
# self.built is an array of the troops you have built, ever.
# Here we use "len(self.built) % len(summonTypes)" to wrap around the summonTypes array
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]
        # Use % to wrap around defendPoints based on friendIndex
        defPon = defendPoints[len(friends) % len(defendPoints)]
        # Command your minion to defend the defendPoint
        hero.command(friend, "defend", defPon)

while True:


Just one hint: Look at the line
defPon = defendPoints[len(friends) % len(defendPoints)]
You’d want to wrap around the array defendPoints, and the part after the modulo looks rigt, but have a look at the part before the %-Operator. len(friends) will stay the same number all the time…



i fixed it to

defPon = defendPoints[friendIndex % len(defendPoints)]

and it works thanks


How do you define friendIndex?


Can you put Solved in your title?


You’re replying to a topic that is almost a year old. The person you are replying to has not been on this board for over a month.