Grim Determination [Help]

# Your goal is to protect Reynaldo

# Find the paladin with the lowest health.
def lowestHealthPaladin():
    lowestHealth = 99999
    lowestFriend = None
    friends = hero.findFriends()
    for friend in friends:
        if friend.type != "paladin":
        if < lowestHealth and < friend.maxHealth:
            lowestHealth =
            lowestFriend = friend
    return lowestFriend

def commandPaladin(paladin):
    canHeal = paladin.canCast("heal")
    lowest_friend = lowestHealthPaladin()
    if lowest_friend:
        if < 550:
            hero.command(paladin, "cast", "heal", lowest_friend)
    if < 100:
        hero.command(paladin, "shield")
    #elif contains_warlock():
    #    target = paladin.findNearest(hero.findByType("warlock"))
    #    hero.command(paladin, "attack", target)
        target = paladin.findNearest(paladin.findEnemies())
        if target:
            hero.command(paladin, "attack", target)

def contains_warlock():
    enemies = hero.findEnemies()
    for enemy in enemies:
        if enemy.type == "warlock":
            return True
    return False

def commandPeasant(friend):
    coins = hero.findItems()
    if len(coins) > 3:
        best_value = 0
        for coin in coins:
            value = coin.value / friend.distanceTo(coin)
            if value > best_value:
                best_value = value
                best_coin = coin
        hero.command(friend, "move", best_coin.pos)

def commandGriffin(friend):
    if contains_warlock():
        target = friend.findNearest(hero.findByType("warlock"))
        target = friend.findNearest(friend.findEnemies())
    if target:
        hero.command(friend, "attack", target)

def commandFriends():
    # Command your friends.
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "peasant":
        elif friend.type == "griffin-rider":
        elif friend.type == "paladin":

while True:
    # Summon griffin riders!
    if > hero.costOf("griffin-rider"):

No errors, seems like I’m covering all aspects. I’ve tried both focusing warlocks and not focusing them, neither work.

Hi @EzDzQzR,
welcome to the CodeCombat discourse.
Sorry for keeping you waiting, and also for my disappointing answer to your problem: I’m afraid there’s not really anything concrete I can do to help you with this level. There’s not right answer. Except one thing: make the griffin-riders and friends return to a central point if there isn’t an enemy. I think that might help.
If that doesn’t work, maybe look at other topics talking about this level, they might give you some inspiration.