Ogre Gorge Gouger/ Python/ Stuck

My character collects one coin and stops

while hero.time < 20:
    # Collect coins
    hero.say("I should pick up a coin")
    items = hero.findItems()
    bestItem = None
    bestValue = 0
    itemsIndex = 0
    
    while itemsIndex < len(items):
        item = items[itemsIndex]
        if item.value / hero.distanceTo(item) > bestValue:
            bestItem = item
            bestValue = item.value / hero.distanceTo(item)
        itemsIndex += 1
    
    while bestItem:
        hero.move(bestItem.pos)
        pass

You are overcomplicating a very simple problem. Restart the level and do it step by step. Delete this line hero.say("I should pick up a coin"). Then you do

item = hero.findNearestItem()
    if item:
        
            
            hero.move(item.pos)

Put that in the first while-loop then you build a fence in the 2nd while loop.

Thank you again @milton.jinich this happens alot to me Lol

It’s okay. I did it before a lot of times.

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.