Pls help in the bane of soldiers

Here is my code:

while True:
    enemies = hero.findEnemies()
    enemy = hero.findNearest(enemies)
    friends = hero.findFriends()
    # Send the first soldier of the friends array towards the enemy.
    for  i in range(0, len(friends)):
        friend = friends[1]
        hero,command(friend, "move", {"x":16,"y":16})
    # i in range(1, n) starts the index at the second element!
    for i in range(1, len(friends)):
        friend = friends[i]
        # Command the remaining soldiers to run away!
        hero.command(friend, "move", {"x":30, "y":36})

only one of the soldiers go to the bomb and it only explodes one bomb

What is Html? (20 chars)

for this you can just do

for friend in friends:
        hero.command(friend, "move", enemy.pos)

@milton.jinich that isn’t very kind, and doesn’t help someone learn.

@Ryan_Wong, you have:


which is making that line of code not work. However, have another look at the two lines above it. You’re only trying to command one soldier, so you don’t need the for loop to go through all of them.



well not really cause each and every single one of them are going to move. In my code at least i have a loop that checks the enemy.

if enemy:
    friend = friends[0]

and t hen a command that moves them to the enemy. I recommend you getting away from the enemy more like


replace that with enemy.pos

Well I did it my way and it worked.

duno…Before i tried but it send about 3 at a time