Help on Reaping Fire

On the level Reaping Fire, my griffin-riders are not responding when I command them to attack the ogres. Can you help me?

Here is my code:


# The goal is to survive for 30 seconds, and keep the mines intact for at least 30 seconds.

def chooseStrategy():
    enemies = hero.findEnemies()
    # If you can summon a griffin-rider, return "griffin-rider"
    if hero.gold >= hero.costOf("griffin-rider"):
        hero.summon("griffin-rider")
        return "griffin-rider"
    # If there is a fangrider on your side of the mines, return "fight-back"
    for enemy in enemies:
        if enemy and enemy.type is "fang-rider":
            return "fight-back"
    # Otherwise, return "collect-coins"
        else:
            return "collect-coins"

def commandAttack():
    # Command your griffin riders to attack ogres.
    enemy = hero.findNearest(hero.findEnemies())
    if enemy and enemy.type is "ogre":
        hero.command("griffin-rider", "attack", "ogre")
    
    
def pickUpCoin():
    # Collect coins
    items = hero.findItems()
    for item in items:
        if item and item.value > 1:
            hero.moveXY(item.pos.x, item.pos.y)
    
def heroAttack():
    # Your hero should attack fang riders that cross the minefield.
    enemy = hero.findNearest(hero.findEnemies())
    if enemy and enemy.type is "fang-rider":
        hero.attack(enemy)
    
while True:
    commandAttack()
    strategy = chooseStrategy()
    # Call a function, depending on what the current strategy is.
    if strategy == "griffin-rider":
        commandAttack()
    if strategy == "fight-back":
        heroAttack()
    if strategy == "collect-coins":
        pickUpCoin()

Are there any ogres? Your commandAttack function specifies that the griffin riders only attack ogres.

But the comments say that the the griffin riders should only attack ogres. I assumed that munchkins and throwers fell into the ogre group.

Try attacking all enemies (if enemy). Also, fangrider should not be hyphenated.

Yeah, I just realized that last part.

Now I am not summoning enough griffin-riders. I am only summoning one.

Here is my new code:



def chooseStrategy():
    enemies = hero.findEnemies()
    # If you can summon a griffin-rider, return "griffin-rider"
    if hero.gold >= hero.costOf("griffin-rider"):
        hero.summon("griffin-rider")
        return "griffin-rider"
    # If there is a fangrider on your side of the mines, return "fight-back"
    for enemy in enemies:
        if enemy and enemy.type is "fangrider":
            return "fight-back"
    # Otherwise, return "collect-coins"
        else:
            return "collect-coins"

def commandAttack():
    # Command your griffin riders to attack ogres.
    friend = hero.findNearest(hero.findFriends())
    enemy = hero.findNearest(hero.findEnemies())
    if enemy: 
        hero.command(friend, "attack", enemy)
        
def pickUpCoin():
    # Collect coins
    items = hero.findItems()
    for item in items:
        if item and item.value > 1:
            hero.moveXY(item.pos.x, item.pos.y)
    
def heroAttack():
    # Your hero should attack fang riders that cross the minefield.
    enemy = hero.findNearest(hero.findEnemies())
    if enemy and enemy.type is "fangrider":
        hero.attack(enemy)
    
while True:
    commandAttack()
    strategy = chooseStrategy()
    # Call a function, depending on what the current strategy is.
    if strategy == "griffin-rider":
        commandAttack()
    if strategy == "fight-back":
        heroAttack()
    if strategy == "collect-coins":
        pickUpCoin()
1 Like

Try defining a single coin using a different method, like hero.findNearestItem. Currently, you are using hero.findItems, which finds an array of items but doesn’t define a particular position of each item or which one to move to. With findNearestItem, you are defining a single position of a single item to move to - the nearest coin.

What character are you using and do you have the ring of speed? You need some speed to get as many grif-riders as possible.

I am using Pender Spellbane and I have the ring of Speed.

I was able to pass the level with Pender but couldn’t get the 60 second bonus with it. Pender just doesn’t have enough health. Are you casting haste? Mana blast? I wound up using Nalfar to get the bonus.

Thanks for the advice

I finished the level! I have been working for a month on it! Thanks!

1 Like

By the way, I got the bonus and won with Tharin

1 Like

Well done! You just need to keep working on it!

1 Like

i need help with my code, my griffin-riders are not responding to the command and also my code maybe has other problems.

def chooseStrategy():
    enemies = hero.findEnemies()
    # If you can summon a griffin-rider, return "griffin-rider"
    if hero.gold > hero.costOf("griffin-rider"):
        return "griffin-rider"
    # If there is a fangrider on your side of the mines, return "fight-back"
    enemy = hero.findNearestEnemy()
    if enemy and enemy.type == "fangrider":
        return "fight-back"
    # Otherwise, return "collect-coins"
    return "collect-coins"

def commandAttack():
    # Command your griffin riders to attack ogres.
    friend = hero.findFriends()
    friends = hero.findFriends()
    if friend in friends:
        hero.command(friend, "attack", enemy)
        for enemy in enemies:
            hero.command(friend, "attack", enemy)
    pass
    
def pickUpCoin():
    # Collect coins
    coin = hero.findNearestItem()
    if coin:
        hero.move(coin.pos)
    pass
    
def heroAttack():
    # Your hero should attack fang riders that cross the minefield.
    if enemy and enemy.pos > hero.pos:
        hero.attack(enemy)
    pass
    
while True:
    commandAttack()
    strategy = chooseStrategy()
    # Call a function, depending on what the current strategy is.
    if strategy == "griffin-rider":
        hero.summon("griffin-rider")
    if strategy == "fight-back":
        heroAttack()
    if strategy == "collect-coins":
        pickUpCoin()

But what happens when the enemy is far away and you see it? Wouldn’t be better to collect coins even if there is a fangrider but if is on the other side of the mines or above the mines?

Here I belive that you want to attack each griffin rider’s nearest enemy, so first first loop over each element from the friends array, then say who is enemy, then check if it exists and if it does, then command to attack.

I belive that this is not necesarry.

Andrei

2 Likes