Diamond Dozen Help Python

I have no idea what is wrong. My code works perfectly fine but right around the half way point my guy starts trying to collect 2 coins in one iteration and that throws him off. He never reachs the 2nd coin but when the new round of coins come hes to far away to get any of the coins in the next iteration. This does not happen for the first 5 or so collections of coins only after a certain point. He normally just stands still once 1 coin has been collected but not after the 5th or so.

# Return the item with the highest valueOverDistance(item)
def findBestItem(items):
    bestItem = None
    bestValue = 0
    itemsIndex = 0
    
    # Loop over the items array.
    # Find the item with the highest valueOverDistance()
    while itemsIndex < len(items):
        if valueOverDistance(items[itemsIndex]) > bestValue:
            bestValue = valueOverDistance(items[itemsIndex])
            bestItem = items[itemsIndex]
        
        itemsIndex += 1
    return bestItem

Ive managed to complete the level but I had to add a wait period after I went to the location of the coin because my guy would keep trying to get the 2nd coin which kept puting me out of range for the next round of coins.

1 Like

Thanks for this. I had the same issue; I was over-collecting coins and failing. Putting on boots with no speed boost and using the time delay both solved the issue for me. I’m guessing this encounter was tuned for default speed boots.