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