[SOLVED] Hunting Party help (Python)

or @Deadpool198 what about you?

2 Likes

Sure…pls post a fresh copy of your code. And you are right about the indent…looking at the pick, it was not obvious that the last line wrapped…it looked like an indent.

2 Likes
# 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", enemy)
        # Command to move east by small steps.
        else:
            hero.command(friend, "move", {“x”: friend.pos.x + 1, “y”: friend.pos.y})
2 Likes

what does this mean?

2 Likes

Try to put this before the if statement and only check if enemy.

Andrei

1 Like

ok so my troops are moving :partying_face: but they just keep going to the left :cry:

3 Likes

and dont attack at all

2 Likes

Can I see the code?

Andrei

1 Like
# 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.
        enemy = hero.findNearestEnemy()
        if enemy:
            hero.command(friend, "attack", enemy)
        # Command to move east by small steps.
        else:
            hero.command(friend, "move", {"x": friend.pos.x + 1, "y": friend.pos.y})
2 Likes

and its a little laggy

2 Likes

Here put friend instead of hero.

Andrei

2 Likes

:partying_face: :partying_face: (sorry couldnt help but put 2 emojis) now im just wondering how to et the bonus

3 Likes

Just put instead of 1 a lower number (like 0.27).

Andrei

1 Like

how do you blur something out? like you did?

2 Likes

im confused on that but, on the bright side i got the bonus!!!

2 Likes

No. I will explain that to you in a PM. And congratulations for completing the level and the bonus! :partying_face:

Andrei

2 Likes

ok and thanks! and thanks to you to @dedreous

4 Likes

Andrei, be sure to cover the ‘badge’ too :wink:

1 Like

quick question, why does a text like this need to be 20 characters?

2 Likes

To prevent people from spamming.

Andrei

1 Like