Reaping Fire - Griffin riders freezing when there is a fangrider

I can pass the level but not the bonus, I think because the griffin riders stop doing anything when there are fangriders present and alive. Really annoying problem. I try to keep them from attacking fangriders by excluding fangriders as a target, but the game does not seem to like my method.
Please help!!

image

# 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"
    enemy = hero.findNearestEnemy()
    if enemy and enemy.pos.x < 53:
        return "fight-back"
    # Otherwise, return "collect-coins"
    else:
        return "collect-coins"

def commandAttack():
    # Command your griffin riders to attack ogres.
    friends = hero.findFriends()
    enemy = hero.findNearest(hero.findEnemies())
    for friend in friends:
        if enemy and enemy.type != "fangrider":
            hero.command(friend, "attack", enemy)
    pass
    
def pickUpCoin():
    # Collect coins
    item = hero.findNearestItem()
    if item:
        hero.move(item.pos)
    pass
    
def heroAttack():
    # Your hero should attack fang riders that cross the minefield.
    enemy = hero.findNearestEnemy()
    if enemy and enemy.pos.x < 53:
        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()   

oh, I have it. dont do hero.command(friend, "attack", enemy) because while the hero is attacking, enemy will be a fangrider. instead, do:

enemy = friend.findNearestEnemy()
if enemy and enemy.type != "fangrider:
hero.command(friend, "attack", enemy)

this will make the griffin-riders attack THEIR nearest enemy, instead of the hero’s.

1 Like

P.S. check fangrider type by clicking them in a level.

Thanks, your explanation makes sense, but a part of the griffin riders now actually don’t do anything, even after new enemies come up they just stay there:

I was able to get the full bonus for this level by changing my code to this:
image
Along with this which I came up last time when trying to survive for as long as possible:
image

Edit:
The lazy part of the griffin riders only start moving once enemies actually come close to the minefield. I have no idea how to influence this mechanic/bug in the game. I tried making them move to a certain position with the hero.command move option within the For Loop but in that case they only stay at that position and do nothing

image

ah ok you could take your last post, make a new topic, and then tag it #bugs

wait you can use an if in your for loop, BUT you need to put it IN the while true loop.
No function.

I admire your perseverance. I’m sure you will become a desirable software developer.
But I guess I don’t understand your last comment, can you please elaborate?

Here’s my current 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"
    enemy = hero.findNearestEnemy()
    if enemy and enemy.pos.x < 53:
        return "fight-back"
    # Otherwise, return "collect-coins"
    else:
        return "collect-coins"

def commandAttack():
    # Command your griffin riders to attack ogres.
    friends = hero.findFriends()
    for friend in friends:
        enemy = friend.findNearestEnemy()
        if enemy and enemy.type != "fangrider":
            hero.command(friend, "attack", enemy)
                
    
def pickUpCoin():
    # Collect coins
    item = hero.findNearestItem()
    if item:
        hero.move(item.pos)
    pass
    
def heroAttack():
    # Your hero should attack fang riders that cross the minefield.
    enemy = hero.findNearestEnemy()
    if enemy and enemy.pos.x < 53:
        hero.attack(enemy)
        
def timeSurvive():
    enemy = hero.findNearestEnemy()
    if hero.time > 35:
        if enemy:
            hero.shield(enemy)
    
while True:
    commandAttack()
    timeSurvive()
    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()   

There is NO BUG and there are multiple ways to command your minions.Search solutions in topics more than 2-3 years old…
Are you sure you will defend this position and when?:

dont revive topic this was solved

Hello, see my post above:

Oh. so, the thing is if-statements in a function commanding minions do not work, but if you use a for loop actually in the while true loop, it will work it is wierd

it is a glitch or something