[SOLVED] Help with Golden Mirage

Hey everyone,
I’ve been stuck on golden mirage (https://codecombat.com/play/level/golden-mirage?) for a while now but I’m stumped, I could do the levels i the mountain before it fine but I can’t seem to do this one.
Here’s my current code:

while True:
    coins = hero.findItems()
    fakeCoins = []
    realCoins = []
    for coin in coins:
        for coin2 in coins:
            if coin2.value == coin.value:
        if not coin in fakeCoins:
    nearCoin = hero.findNearest(realCoins)
    if nearCoin:

It doensn’t really make sense but I can’t work out how to go about solving it, could anyone give me some hints about what code I should use to solve this level that would be great, Thanks. :grin:

1 Like

It can’t really work because in that code you’ll end up comparing the same coin with itself so all coins are fake in the end

check the len of fakeCoins
that should give you a hand

for coin in coins:  # lets say coin = 0
        for coin2 in coins: # lets say coin2 = 0
            if coin2.value == coin.value:  # if coins[0].value == coins[0].value
                fakeCoins.append(coin) # put coins[0] in the array.
1 Like

Thanks so much man, I’ve done the level now, Thanks! That was a really helpful description of the problem and it really cleared it up for me. :hugs:

1 Like

@Deadpool198 Hi. I do not understand exactly how to get my character to compare two different coins. My character is just acting the same way as it did with the sample code. Here is my code:

# Collect 10 real coins.

while True:
    coins = hero.findItems()
    coinIndex = 0
    correctCoin = 0
    if coins and coinIndex < len(coins):
        # The following code will help you debug:
        coin = coins[0]
        if coin.value != correctCoin:
            hero.moveXY(coin.pos.x, coin.pos.y)
        # When ready, delete the previous code and solve.

P.S: The reason that I have been asking for so much help lately is that I have been unable to use CodeCombat for 8 months. I’m still getting warmed up again. Please excuse all of my pleas for help.

I’m afraid you’re not really going about this the right way, I also found this level probably one of the hardest levels I’ve done so far. What you’ve got to try and use is the double array stuff from levels like: “ice hunter”, “highlanders” and “the spy among us”. I can see from the leader-boards you’ve just done them, you have to apply those skills to this level.
Also, not trying to be self-righteous, but look at my code above and see what kind of techniques you need to use if you’re finding it very difficult, because my code used the right principles just with some technical mistakes.
I hope this helps you, and don’t worry about asking for help, It’s fine this level’s really hard, although just wait until you get to the glacier and see levels like “serpent savings” which are literally impossible, it suddenly says use the API, although I have no idea what an API is and it hasn’t explained it any level either, ah well sorry for that short rant, I think I need some coding help too. LOL)

Hello, I have been stuck on this level for some time now, could you help me with it? Thanks
This is my code

# Collect 10 real coins.
coins = hero.findItems()
fakeCoins = [ ]
realCoins= [ ]
while True:
    for i in range(len(coins)):
        if  coins[i] in fakeCoins:
        for j in range(len(coins)):
            if j <= i:
            if coins[i].value == coins[j].value:
        nearCoin = hero.findNearest(realCoins)
        if nearCoin:

first of all, think about this:

What will the coins array hold half way through the level when all the coins are different?

You’ve put this to define it (the array), but where have you added to it?
What’s it going to find here?


I’m not sure what you’ve got this here for, but it’s not necessary.

Also here, I don’t want to give away to much, but what is this for? None of the other levels I’ve seen use that.

What you’ve added to the fakeCoins array is a number, 3 or 2 or 1 or whatever.
But when you compare a coin to the fakeCoins array here:

You’re comparing a coin (an object) with a number (the coin’s value).

You’ve got one more mistake, which is the same mistake I made, look carefully at your code once you’ve corrected everything else, and then look at @Gabriel_Dupuis’s comment. Which should help you solve that problem.
That’s all that’s wrong, and now you need to add something, which is add to the realCoins array because at the moment it’s empty for the whole level.

Think about how you’re going to add to it, and what conditions you’re going to set to decide whether you add to it.

If you’re still having trouble with this level, review the previous levels:

The spy among us:


I hope you solve the level, and that this has been a help.
:lion: :lion: :lion: