[SOLVED] I need help on code combat reaping fire

def chooseStrategy():
enemies = self.findEnemies()
enemy = self.findNearest(enemies)
if self.gold > self.costOf(“griffin-rider”):
return “griffin-rider”
# If you can summon a griffin-rider, return “griffin-rider”
elif enemy:
if enemy.type is “fangrider” and self.distanceTo(enemy) < 30:
return “fight-back”
# If there is a fangrider on your side of the mines, return “fight-back”
return “collect-coins”
# Otherwise, return “collect-coins”

def commandAttack():
# Command your griffin riders to attack ogres.
for griffin in self.findByType(“griffin-rider”):
if griffin:
enemy = griffin.findNearestEnemy()
if enemy:
self.command(griffin, “attack”, enemy)

def pickUpCoin():
# Collect coins
coin = self.findNearest(self.findItems())
if coin:

def heroAttack():
# Your hero should attack fang riders that cross the minefield.
enemy = self.findNearest(self.findEnemies())
if enemy and self.distanceTo(enemy) < 30:
while True:

strategy = chooseStrategy()
# Call a function, depending on what the current strategy is.
if strategy == "griffin-rider":
if strategy == "fight-back":
if strategy == "collect-coins":

Hi North,

Welcome to the forum!

You’ve used ‘self’ in the code, which hasn’t been used in the instructions for CoCo for about 4 years hmmm?

Please have a go at writing your own code - the only way you’ll learn is to try it yourself.

If you still need help then post the code here (try to get all of it formatted too please).

Good luck!


Hi Jenny,
By the way I solved it myself.

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.