Sarven Treasure - Python


#1

I am trying to complete this level by having my character just run and pick up gold at first and then start fighting. All during this time I wan’t to be able to us a flag to tell my character to go to a teleporter. When I run the code it says "Hard execution limit of 3000000 reached? Any help or suggestions would be great. Thank you.

loop:
    items = self.findItems()
    item = self.findNearest(items)
    enemies = self.findEnemies()
    enemy = self.findNearest(enemies)
    green = self.findFlag("green")
    black = self.findFlag("black")
    violet = self.findFlag("violet")
    flags = self.findFlags()
    
    while self.health > 1000:    
        if item:
            self.moveXY(item.pos.x, item.pos.y)
        elif flags:
            if green:
                self.pickUpFlag("green")
                pass
    while self.health < 1000 and self.health > 500:
         if enemy:
            if self.distanceTo(enemy) < 10:
                if self.isReady("cleave"):
                    self.cleave(enemy)
                else:
                    continue
        elif item:
            self.moveXY(item.pos.x, item.pos.y)
        elif flag:
            if green:
                self.pickUpFlag("green")
                pass

#2

what do you have
speed ring and softened leather boots are recommended
and also any good sword at least 200 damage


#3

That means you have an infinite loop somewhere. Can you see any such loops in your code?
You might want to replace the parts with while self.health with if and else if.


#4

You must update your world view (search for items, enemies, flags … inside each while loop
Otherwise will be stuck in the first while loop, you’ll pick the only item you searched for, and the do nothing until you run out of instructions.

An empty while loop will be executed a million of times in less than a fraction of a second.


#5

OK thank you very much!