[SOLVED] Help with Steelclaw Gap please

hi. i don’t know what i need to do with the percent sign. here is my code:

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

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]
        # Use % to wrap around defendPoints based on friendIndex
        
        
        # Command your minion to defend the defendPoint
        
        

while True:
    summonTroops()
    commandTroops()

thanks.

After this, put this:

defendPos = defensePoints[friendIndex % len(defensePoints)]
hero.command(friend, "defend", defendPos)

Tell me if you need any more assistance at this level, ok?

1 Like

@AnSeDra thats still incorrect
Also, friendIndex isn’t defined

2 Likes

they all go to the same spot here’s the new code

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

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]
        friendIndex = 0
        # Use % to wrap around defendPoints based on friendIndex
        defendPos = defendPoints[friendIndex % len(defendPoints)]
        hero.command(friend, "defend", defendPos)
        friendIndex += 1

while True:
    summonTroops()
for friendIndex, friend in enumerate(friends): # Now you defined friendIndex
    defendPosition = defendPoints[friendIndex % len(defendPoints)]
1 Like

Instead of friendIndex put the variabile i.
Does it work now?

1 Like

You got a typo, it is defendPos not defensePos

2 Likes

Use this if possible

for friendIndex, friend in enumerate(friends): # Now you defined friendIndex
    defendPosition = defendPoints[friendIndex % len(defendPoints)]
2 Likes

or just do this:

hero.command(friend, 'defend', defendPoints[friendIndex % len(defendPoints)])
# or do this
hero.command(friend, 'defend', defendPosition)
2 Likes

I corrected that now. Thanks!

1 Like

it just happened when i changed the variable to i. thanks.

1 Like

ur welcome, wanna battle me in ace of coders?

2 Likes

No problem! And congratulations on making the level! :partying_face:

1 Like

i’m not that good so no but maybe in like a month or two if your available?

1 Like

thanks @EpicCoder999 and @AnSeDra.

1 Like

No problem! Glad I could help! :slightly_smiling_face:
Now could you mark the solution?

1 Like

sure. though i am trying to get the 60 seconds bonus. here it is without the bonus.
Mod edit: solution removed

@Deadpool198 or @ActualllOLLIEpop, please one of you delete the solution so others won’t be able to use it and cheat at this level. About the bonus, try resummiting until you get a good seed and the bonus. This is how I got the bonus at least. :wink:

1 Like

sorry @AnSeDra, i thought that you meant that i should post my finished code here. thanks @Deadpool198 for deleting it when i was gone :grin:

No problem! Just try to not post solutions again, all right?

1 Like