Toil and Trouble-- solvable with wrong strategy

Try fixing up your indentation. The syntax checker isn’t all that perfect when spitting out the error message.

Okay, I fixed it and it is now error free:

def ChooseTarget(friend):
    enemies = self.findEnemies()
    witches = self.findByType("witch", enemies)
    if friend.type == "soldier":
        target = friend.findNearest(witches)
    elif friend.type == "archer":
        target = friend.findNearest(enemies)
    return target
       
loop:   
    friends = self.findFriends()       
    for friend in friends:
            target = ChooseTarget(friend)
            #self.say("Friend is " + friend + "and target is " + target)
            self.command(friend, "attack", target)

For some reason, my archers all bunch together and move to the top. So the throwers on the bottom live.

Then they attack the Ogre on the top while my soldiers move forward to attack the witches. Eventually the top Ogre and the bottom witch die, but the remaining throwers, Ogre and Witch mow down what is left of my forces at that point.

I have already gone through this and many other variations which is why I may have appeared to have been overthinking it earlier. Any help at this point would be much appreciated.

Edit: Okay, I got it. The problem was, my hero apparently couldn’t see the throwers on the bottom. I changed enemies to friend.findEnemies() as you suggested and it worked.

Thanks a bunch trotod!

For me, unfortunately, this code doesn’t work :frowning: