# This field is covered in firetraps. Thankfully we've sent a scout ahead to find a path. He left coins along the path so that if we always stick to the nearest coin, we'll avoid the traps.
# This canyon seems to interfere with your findNearest glasses!
# You'll need to find the nearest coins on your own.
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 distance < nearestDistance:
# Set nearest to coin
nearest = coin
# Set nearestDistance to distance
nearsetDistance = distance / 2
# If there's a nearest coin, "_" to its position. You'll need "_" so you don't cut corners and hit a trap.
if nearest:
(nearest.pos.x, nearest.pos.y) # –trying not to give the answer
I believe my code is correct, but my hero dies every time. My friend have the exact problem on sand snakes yesterday. This happened two times. Even though he restarted it and he retyped the code and it worked(and I can do the same), can you guys please fix the bug so that it won’t happen to other people. Thank You