Help on Grim Determination

I suppose that’s true, but it’s not like the coins spawn so fast you need both peasants to go for different coins.

Now my peasants are going for different coins, and I don’t have any errors, but my code is still not working.

Code:


# 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":
            continue
        if friend.health < lowestHealth and friend.health < friend.maxHealth:
            lowestHealth = friend.health
            lowestFriend = friend

    return lowestFriend

def commandPaladin(paladin):
    enemy = hero.findNearest(hero.findEnemies())
    # Heal the paladin with the lowest health using lowestHealthPaladin()
    lowestFriend = lowestHealthPaladin()
    if lowestFriend and paladin.canCast("heal"):
        hero.command(paladin, "cast", "heal", lowestFriend)
    # You can use paladin.canCast("heal") and command(paladin, "cast", "heal", target)
    # Paladins can also shield: command(paladin, "shield")
    # And don't forget, they can attack, too!
    if enemy:
        hero.command(paladin, "attack", enemy)
    if paladin.health < 200:
        hero.command(paladin, "shield")

def commandPeasant(friend,index):
    coins = hero.findItems()
    coin = coins[index]
    hero.command(friend, "move", coin.pos)

def commandGriffin(friend):
    enemy = hero.findNearest(hero.findEnemies())
    if friend and friend.type is "griffin-rider":
        if enemy:
            hero.command(friend, "attack", enemy)

def commandFriends():
    # Command your friends.
    friends = hero.findFriends()
    peasantIndex = 0
    for friend in friends:
        if friend.type == "peasant":
            commandPeasant(friend,peasantIndex)
            peasantIndex += 1
        elif friend.type == "griffin-rider":
            commandGriffin(friend)
        elif friend.type == "paladin":
            commandPaladin(friend)

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

I see your problem. Your paladins aren’t healing themselves, which is a problem.
You need to replace this:

with this:

if lowestFriend and paladin.cancast("heal"):
    hero.command(paladin, "cast", "heal", lowestFriend)
ELIF enemy:
    hero.command(paladin, "attack", enemy)

The shield part is kind of unnecessary
btw dont even bother killing the warlock. Another one will just spawn if you kill him (I tried it, he suicide explodes, and that kind of hurts)