Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Help in Toil and Trouble


i have a problem in Toil and Trouble.Witches win every time.My soldiers die. I can not make it work . Here is my code:

def chooseTarget(friend):
    if friend.type == "archer":
        if len(self.findByType("thrower")) > 0:
            return friend.findNearest(self.findByType("thrower"))
        elif len(self.findByType("witch")) > 0:
            return friend.findNearest(self.findByType("witch"))
            return friend.findNearest(self.findEnemies())
    elif friend.type == "soldier":
        return friend.findNearest(self.findByType("witch"))

    friends = self.findFriends()
    for friend in friends:
        # Use your chooseTarget function to decide what to attack.

help me plzzzzzzzzzzzzz! Thank you very much!


Please format your code according to the FAQ. It makes it easier for us to be able to read your code and figure out the problem. Please do this in the future.


FYI, you have to make your soldiers attack the nearest witch to them FIRST. Otherwise the soldiers won’t have enough health to take out the witches. But, the archers are fine. Also, it has to be with your friends vision not yours.


Thank you , i did make it.

TOIL AND TROUBLE in the mountain