# Grim determination solved

**URL:** <https://discourse.codecombat.com/t/grim-determination-solved/6827>\
**Category:** Uncategorized\
**Created:** [February 24, 2016, 6:17pm UTC](https://discourse.codecombat.com/t/grim-determination-solved/6827 "2016-02-24T18:17:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lundor5](https://avatars.discourse-cdn.com/v4/letter/l/7993a0/32.png) [@lundor5](https://discourse.codecombat.com/u/lundor5)\
**Post date:** [February 24, 2016, 6:17pm UTC](https://discourse.codecombat.com/t/grim-determination-solved/6827/1 "2016-02-24T18:17:21Z")

</div>

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

```python
  # 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")
```

---

<div class="post-metadata">

**Author:** ![lundor5](https://avatars.discourse-cdn.com/v4/letter/l/7993a0/32.png) [@lundor5](https://discourse.codecombat.com/u/lundor5)\
**Post date:** [February 24, 2016, 6:21pm UTC](https://discourse.codecombat.com/t/grim-determination-solved/6827/2 "2016-02-24T18:21:24Z")

</div>

i beat it so it is solved

---

<div class="post-metadata">

**Author:** ![sir-sonic-Destroyer](https://avatars.discourse-cdn.com/v4/letter/s/838e76/32.png) [@sir-sonic-Destroyer](https://discourse.codecombat.com/u/sir-sonic-Destroyer)\
**Post date:** [March 2, 2016, 2:47pm UTC](https://discourse.codecombat.com/t/grim-determination-solved/6827/3 "2016-03-02T14:47:01Z")

</div>

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!
