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 friend.findNearestEnemy:
hero.command(friend, "attack", enemy)
# Command to move east by small steps.
You have to check if there is an enemy using friend.findNearestEnemy(). If that enemy exists, then command your friends to attack that enemy, else command them to move friend.pos.x + 1, friend.pos.y
If it gives you an error, then you probably haven’t checked if a friend exists. If a friend exists, then they need to find the nearest enemy to them. If that enemy exists, they need to attack it, otherwise they need to move to the right.
while True:
friends = hero.findFriends()
enemy = hero.findNearestEnemy()
# Use for-loop and for each friend:
for friend in friends:
friendAttackEnemy = friend.findNearestEnemy()
# If they see an enemy then command to attack.
if friendAttckEnemy:
hero.command(friend, "attack", enemy)
# Command to move east by small steps.
else:
hero.command(friend, "move", friend.pos.x, friend.pos.y + 1)