Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Need help on Reaping Fire level [SOLVED]


#1

Here is my code:

def commandAttack():
    friends = hero.findFriends()
    for friend in friends:
        fEnemies = hero.findEnemies()
        for fEnemy in fEnemies:
            if fEnemy.type != "fangrider":
                hero.command(friend, "attack", fEnemy)

Everything runs smoothly; the only problem is the griffin riders always die right away, and I can’t collect gold to replace them because I’m busy fighting the fangriders. Can someone please help me?


#2

Your function commandAttack() is too complicated. Try something more simple:

def commandAttack():
    friends = hero.findFriends()
    for friend in friends:
        # fEnemy  -> let your friend find the nearest enemy
          # without excluding fangriders  --> any enemy
        # if fEnemy and fEnemy's health greater  than zero
            # hero command your friend to attack the fEnemy
        # else:
            # hero command friend to defend some spot in enemy territory

#3

Thank you for replying.

I lasted 5-7 seconds longer than before. The problem now is the second griffin rider I summon fights the fangriders on my side of the minefield, allowing the ogres to run into the bomb things.


#4

I pass the level with the bonus with your modified code. Be bolder - {‘x’: 100, ‘y’: 40} or submit several times :slight_smile:
Edit: Delete the code from your second post - this is a complete solution. You can even delete most of the code from the first post - only the faulty def commandAttack(): can remain intact.


#5

It works now! Thank you so much! :grin:
Edit : (Sorry, I didn’t know)