[SOLVED] Hunting Party help (Python)

can someone please tell me how to get my troops to move im confused on that, here is my code so far

# You can use findNearestEnemy() on your soldiers to get their nearest enemy instead of yours.
while True:
    friends = hero.findFriends()
    # Use for-loop and for each friend:
    for friends in friends:
        # If they see an enemy then command to attack.
        enemy = hero.findNearestEnemy()
        # Command to move east by small steps.
    else:
        hero.command(friend, "move", target)

Put 4 spaces before those lines. And try to check if the enemy exists and then attack it before the else. And you forgot to say what position is in the target variabile. Do you want me to show you what target should be?

Andrei

yes please (20 characters)

Ok. Here it is:
target = {“x”: friend.pos.x + 1, “y”: friend.pos.y}

Andrei

when i added it to the code the screen immediately showed this

You can delete the target =. And after you find out the enemy check if it exists and if so, attack it. After that put the else (inside the for loop).

Andrei

You indented the line too far.

@dedreous i didnt indent at all

Here put friend instead of hero.

Andrei

Here you have a error. Try

for friend in friends

So the code will run corectly.

Andrei

the screen is still showing this

Try to correct this too.

Andrei

sorry what do you want me to do? do you want me to indent the else?

So, put an if ststement and check if enemy exists and if so, command the friend to attack. After that put the else but inside the for loop.

Andrei

so you want it like this?

if enemy = friend.findNearestEnemy():
            hero.command(friend, "attack", target)

here is all the code

# You can use findNearestEnemy() on your soldiers to get their nearest enemy instead of yours.
while True:
    friends = hero.findFriends()
    # Use for-loop and for each friend:
    for friend in friends:
        # If they see an enemy then command to attack.
        if enemy = friend.findNearestEnemy():
            hero.command(friend, "attack", target)
        # Command to move east by small steps.
        else:
            hero.command(friend, "move", {“x”: friend.pos.x + 1, “y”:    friend.pos.y})

Here attack the enemy.

Andrei

Gtg sorry. :cold_sweat:

Andrei

@dedreous can u help then?