Help with Rich Forager

I’m having trouble with the level Rich Forager… (this is my first post)
Please help, BTW this is python.

loop:
    flag = self.findFlag()
    enemy = self.findNearestEnemy()
    item = self.findNearestItem()


    if flag:
        self.pickUpFlag(flag)

    elif enemy:
        self.attack(enemy)
        
    elif item:
            pos = item.pos
            itemX = pos.x
            itemY = pos.y
            self.moveXY(pos.x, pos.y)

Code looks fine on first glance; what problem are you seeing (just getting killed?) You might want to use cleave and make sure you have enough armor to survive.

1 Like

Why define ItemX and ItemY if you aren’t going to use them? If you define them you might as well use them in your code like

self.moveXY(ItemX, ItemY)

Other than that, just make sure you have a good amount of help and good luck with the level.

Hey Kyang,
I had trouble at first too, but used “cleave” to much success. Part of the trick is placing a flag slightly before the enemies to allow them time to bunch up around you AND avoid being hit too much.

This was the topic I was in about using loops in Rich Forager. Not sure if it would help too:

http://discourse.codecombat.com/t/level-rich-forager/1885?u=romanriot

My hero is just plain standing there, what do I do. After I go through it she just stands there, not getting killed though. Can u help?

nvm I forgot about falling the flags, now i just die, I don’t have enough gems to buy more armor

1 Like