[SOLVED] Stuck on hunting party

No. I finished all the levels that are currently in the game (and a few ones created by Chaboi).

help my middle group survives but the side ones don’t. Please help.

while True:
    friends = hero.findFriends()
    enemy = self.findNearestEnemy()
    # Use for-loop and for each friend:
    for friend in friends:
        # If they see an enemy then command to attack
        if enemy:
            hero.command(friend, "attack", enemy)
        # Command to move east by small steps.
        else:
            hero.command(friend, "move", {"x": friend.pos.x + 0.4, "y": friend.pos.y})

Here try to move with less steps (somewhere from 0.25 will do just fine).

Andrei

still not working the side won’t even attack

maybe it is a bug. can you try it youself?

It’s not a bug in the game…you just need to tune your logic a bit finer.

I’d recommend distinguishing between the archers and soldiers, having the soldiers attack directly and keeping the archers at a safe distance while firing away.

But the soldiers on the flanks don’t even attack while my code works fine on the ones in the middle.

Well, no one has mentioned it yet, but using ā€˜self’ is showing that you acquired this code from elsewhere. ā€˜self’ was replaced back around/before 2017.

Anyway, you are only identifying enemies that the hero can see…not ones that your friends can.

Thanks you helped me a lot I changed self to friend and it worked.

2 Likes