type or paste code here
```# 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 = friend.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})
please format your code properly using the button
I dont know how
Falcons118
use the button and paste your code inside it
1 Like
Hmm, this is quite a tricky one. I would recommend adding something like (this is an idea not actual code):
if friend’s health < certain amount and friend’s distance to enemy is < certain distance:
move away to a safe place (remember it should probably not be a precise coordinate, because all three groups follow the same code, so it might not work for all of them.)
It will probably require quite a lot of testing, and submitting a few times, but you should get it eventually.
Danny
4 Likes