Need help on Grim Determination

I still can’t figure out how to complete Grim Determination.
Please: I ask for someone to please walk me through on how to complete the level!

I have not worked on the level yet, so I can not help you. However the first step to getting assistance is posting your troubled code encased in tripple barticks ( ` ).

Write functions commandPeasant and commandGriffin first.
The peasant should help you to collect coins. Just search the nearest coin to him and command him to move there.
Griffins should attack enemies, just findNearestEnemy and command to attack it.

Inside while loop you need check if you have enough gold to summon a griffin and summon it if it is.

And the last - paladins. Check if she can cast “heal”, then command her to heal the lowestHealthPaladin().
If she can’t cast, then attack the nearest enemies.

Also you can use shield for paladins if their have low health.