# Ogre Witches have some unpleasant surprises ready for you. def chooseTarget(friend): friends = hero.findFriends() for friend in friends: soldier = hero.findNearest(hero.findByType("soldier") if friend and friend.type == "soldier": return "witch" else: return "enemy" # 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() enemy = hero.findNearestEnemy() for friend in friends: hero.command(friend, "attack", chooseTarget()) pass
Been messing with various code on this level and cannot get through it. My latest code above seems to have some kind of parsing t colon error? Help!