hero.requestSteelclawGapHelp()

I have no idea what my soldiers are doing, but it’s not what I want them to do.

Please format your code using this button </>

1 Like
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.gold >= hero.costOf(type):
        hero.summon(type)

def commandTroops():
    friends = hero.findFriends()
    for i in range(len(friends)):
        friend = friends[i]
        index = 0
        # Use % to wrap around defendPoints based on friendIndex
        defendPoint = friend % 4
        # Command your minion to defend the defendPoint
        hero.command(friend, "defend", defendPoints[index])
        index += 1

while True:
    summonTroops()
    commandTroops()

Command troops is the problem. You don’t need all the index stuff. It should look like this

defendPoint = defendPoints[i%len(defendPoints) ]
hero.command(friend, "defend", defendPoint)

And also it says the friend’s index, not the friend itself wrapping around 4, why is it 4? The length of the summonTypes is 8.