Hello, I have been stuck on this level for a while and finally decided to ask for help. I don’t understand what i’m doing wrong.
Here’s my code:
while True: coins = hero.findItems() coinIndex = 0 nearest = None nearestDistance = 9999 # Loop through all the coins to find the nearest one. while coinIndex < len(coins): coin = coins[coinIndex] coinIndex += 1 distance = hero.distanceTo(coin) # If this coin's distance is less than the nearestDistance if self.distanceTo(coin) < nearestDistance: # Set nearest to coin item = hero.findNearestItem() # Set nearestDistance to distance nearestDistance = distance # If there's a nearest coin, move to its position. You'll need moveXY so you don't cut corners and hit a trap. self.moveXY(nearest.pos.x, nearest.pos.y)