[SOLVED] Reaping Fire (python)

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"
    else:
        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:
        self.move(coin.pos)
    
def heroAttack():
    # Your hero should attack fang riders that cross the minefield.
    enemy = self.findNearest(self.findEnemies())
    if enemy and self.distanceTo(enemy) < 30:
        self.attack(enemy)
loop:
    commandAttack()
    strategy = chooseStrategy()
    # Call a function, depending on what the current strategy is.
    if strategy == "griffin-rider":
        self.summon("griffin-rider")
    if strategy == "fight-back":
        heroAttack()
    if strategy == "collect-coins":
        pickUpCoin()

1 Like

What happens when you run the code?

1 Like

1 Like

you’re not wearing boots that include the move method. Rookie mistake. :stuck_out_tongue_winking_eye:

Edit: why are you using self instead of hero?

1 Like

Last time hero. was replased with self. . I’m not sure, about six months ago or a littl bit more. It was somwhere here on the forum. And now they both are working, but in a few last levels it was given self. as an example in code hints. So, as for me personally, I use self. writing code from a blank page and hero. while copypasting my old functions)

1 Like

hero works ‘faster’

What boots do I wear? :face_with_raised_eyebrow:

1 Like

Any boots with the move method. I’d pick whatever ones are the fastest and include it. Your current boots only have moveXY and your code is using move.

1 Like

1 Like

?
(like this? or another one)

1 Like

Any of the other boots but those.

FacePalm03

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

def commandAttack():
    # Command your griffin riders to attack ogres.
    for griffin in hero.findByType("griffin-rider"):
        if griffin:
            enemy = griffin.findNearestEnemy()
            if enemy:
                hero.command(griffin, "attack", enemy)
    
def pickUpCoin():
    # Collect coins
    coin = hero.findNearest(hero.findItems())
    if coin:
        hero.move(coin.pos)
    
def heroAttack():
    # Your hero should attack fang riders that cross the minefield.
    enemy = hero.findNearest(hero.findEnemies())
    if enemy and hero.distanceTo(enemy) < 30:
        hero.attack(enemy)
loop:
    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()

2 Likes

@MunkeyShynes It got to work but my code still doesn’t work the minefield explodes.

1 Like

I used your code with Tharin and passed the level. No 60 second bonus though. Can you post a screenshot of your equipment?

1 Like

1 Like

Equip your wolf pet. He catches arrows and will help you survive a few seconds longer. Also, you are using “for loops” in your code but using Programmaticon 3 for your program book. You need Programmaticon 4 to use for loops. Let me know how those two changes work out and we’ll go from there if it still doesn’t pass.

1 Like

I changed the Progammaticon to 4 I accidentally equipped 3 lol

1 Like

@MunkeyShynes I don’t think I have the wolf?

Oh. Are you a subscriber? Also, I see you have the invisibility ring but aren’t using it. Try using it to last a while longer after the mines blow up.

I can’t tell with the helmet on, which hero are you using?

1 Like

I will try that.

And i’m using tharin.