Grim determination solved


#1

My griffin riders dont attack and my hero summons only one and my peasants just walk into each other and do nothing but try and walk into each other

  # Your goal is to protect Reynaldo

# Find the paladin with the lowest health.
def lowestHealthPaladin():
    lowestHealth = 99999
    lowestFriend = None
    friends = self.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):
    # Heal the paladin with the lowest health using lowestHealthPaladin() 
    if paladin:
        lowPaladin = lowestHealthPaladin()
        if lowPaladin:
            self.command(paladin, "cast", "heal", lowPaladin)
            lowPaladin.say("paladin healed")
    # You can use paladin.canCast("heal") and command(paladin, "cast", "heal", target)
    # Paladins can also shield: command(paladin, "shield")
        else:
            self.command(paladin, "shield")

def commandFriends():
    # Command your friends.
    friends = self.findFriends()
    for friend in friends:
        if friend.type == "peasant":
            commandPeasant(friend)
        elif friend.type == "griffin-rider":
            commandGriffin(friend)
        elif friend.type == "paladin":
            commandPaladin(friend)
def commandGriffin(griffin):
    enemy = griffin.findNearest(griffin.findEnemies())
    self.command(griffin, "attack", enemy)
    
def commandPeasant(peasant):
    coin = peasant.findNearest(peasant.findItems())
    self.command(peasant, "move", coin.pos)
    
loop:
    commandFriends()
    # Summon griffin riders!
    self.summon("griffin-rider")

#2

i beat it so it is solved


#3

can you help me? I just don’t get it.Branches confuse me.here’s my code:

Find the paladin with the lowest health.

def lowestHealthPaladin():
lowestHealth = 99999
lowestFriend = None
friends = self.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):
# Heal the paladin with the lowest health using lowestHealthPaladin()
# 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 paladin:
lowPaladin = lowestHealthPaladin()
if lowPaladin:
self.command(paladin, “cast”, “heal”, lowPaladin)
lowPaladin.say(“paladin healed!”)
else:
self.command(paladin, “shield”)

def commandFriends():
# Command your friends.
friends = self.findFriends()
for friend in friends:
if friend.type == “peasant”:
commandPeasant(friend)
elif friend.type == “griffin-rider”:
commandGriffin(friend)
elif friend.type == “paladin”:
commandPaladin(friend)

def commandGriffin(griffin):
self.summon(“griffin-rider”)
enemy = griffin.findNearest(griffin.findEnemies())
self.command(griffin, “attack”, enemy)
def commandPeasant(peasant):
coin = peasant.findNearest(peasant.findItems())
self.command(peasant, “move”, coin.pos)
loop:
commandFriends()
# Summon griffin riders!