Here is my code:
# Ogre Witches have some unpleasant surprises ready for you. # Define a chooseTarget function which takes a friend argument # Returns a target to attack, depending on the type of friend. # Soldiers should attack the witches, archers should attack nearest enemy. def chooseTarget(friend): enemies = self.findEnemies() enemy = self.findNearest(enemies) witches = self.findByType("witch", enemies) witch = self.findNearest(witches) if friend.type is soldier: self.command(soldier, "attack", witch) if friend.type is archer: self.command(archer, "attack", enemy) loop: friends = self.findFriends() soldier = self.findByType("soldier", friends) archer = self.findByType("archer", friends) for friend in friends: # Use your chooseTarget function to decide what to attack. target = chooseTarget(friend) if target: if target.type is witch: self.command(friend, "attack", target) if target.type is enemy: self.command(friend, "attack", target)
I don’t get how this does not work. Please help me!!!