# 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
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.
hero.moveXY(coin.pos.x, coin.pos.y)
I don’t do levels the way it asks me to so I just did it using moveXY
That is cheating! Bad boy!
hey but it works for this and cubic minefield
tut tut, how naughty
I’m giving you a answer do you want to do it my way or the instructions way
I have worked it out the legit way
@milton.jinich, if you want to dodge a challenge and learn nothing that’s fine, but don’t encourage other people to do it as well.
@QinWentian, your code is almost right.
You go to the trouble of creating the nearest variable and then you don’t use it?
sorry Just done it(20)
1 Like
Thank you! So glad I have a nice forum to help me out
1 Like
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.