# Sand Snakes - My Player is Lazy

I need help here.

``````# 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.
nearestCoin = hero.findItems()
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 nearestCoin < nearestDistance:
# Set nearest to coin
nearest == nearestCoin
# 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(coins.pos.x, coins.pos.y)

``````
1 Like

Any ideas on how to get me guy to ACTUALLY MOVE?

1 Like

I’ll be able to check your code in a few minutes, but I’ve noticed that you’ve placed `hero.moveXY` underneath the while True loop, so it’ll never run.

1 Like

Put the hero.moveXY in the while True loop

1 Like

Did that, the computer doesn’t recognize ‘x’

1 Like

you should look at the nearest coin not the list “coins” because you need a singular object to check it’s position

2 Likes