In the level Toil and Trouble, my soldiers go their separate ways but they attack the ogres. Does anyone know why?
# Ogre Witches have some unpleasant surprises ready for you. # Define a chooseTarget function which takes a friend argument # Returns the a target to attack, depending on the type of friend. # Soldiers should attack the witches, archers should attack nearest enemy. while True: friends = hero.findFriends() for friend in friends: # Use your chooseTarget function to decide what to attack. enemy = hero.findNearest(hero.findEnemies()) if enemy and enemy.type is "witch" and friend.type is "soldier": hero.command(friend, "attack", enemy) if enemy and friend.type is "archer": hero.command(friend, "attack", enemy)