Sarven Desert - Hoarding Gold

It’s possible that there is something wrong with this level.

When running it from the IDE (shift+return), it’s possible for your character to pick up a coin after reaching 25 coins. When you return to the X to tell the archer how much gold you have, the character will have 26 coins, but say he has 25. Then you fail the level.

When submitting the solution, which randomizes the coin placements, the character may pick up exactly 25, then go to the archer and say “25” and pass the level.

This is a bit confusing for the user as the IDE-ran solution fails but the submitted solution can actually be correct. I only found this out after hardcoding hero.say(totalGold +1) to see if I could pass by cheating.


It works for me when I run from IDE. Could you post your code, there might be a bug in it. It could also be that the sprite for the character just barely touches the coin. Which hero do you use to complete the level?


I use Thunderfist.

Here is the solution which passes from Submit:

totalGold = 0
while True:
    coin = hero.findNearestItem()
    if coin:
        # Pick up the coin.
        hero.moveXY(coin.pos.x, coin.pos.y)
        # Add the coin's value to totalGold.
        # Get its value with:  coin.value
        totalGold += coin.value
    if totalGold >= 25:
        # This breaks out of the loop to run code at the bottom.
        # The loop ends, code after the loop will run.

# Done collecting gold!
hero.moveXY(58, 33)
# Go to Naria and say how much gold you collected.

Your code is identical to mine’s. I tested with Thunderfist and it ran fine. Could’ve been just a little bug in the system.


I think that happens sometimes with randomly genrerated levels. It works in one pass and does not in another.
I think this random behaviour is explained somewhere shortly.

Actually, you could improve your program in order to work better (see it as an challenge):

You could either say the actual gold value (you need a sensing stone for that) or watch your path while going to the archer or make sure that you collect the coins in a way that there is no coin between you and the archer when you have finished…


write mabye you can win with this.:slight_smile: