I really need help I can’t figure it out I’ve worked on it for a long time and it still doesn’t work here is my code:
farthest = None
maxDistance = 0
enemyIndex = 0
enemies = hero.findEnemies()
# Look at all the enemies to figure out which one is farthest away.
while enemyIndex < len(enemies):
target = enemies[enemyIndex]
enemyIndex += 1
# Is this enemy farther than the farthest we've seen so far?
distance = hero.distanceTo(target)
if distance > maxDistance:
maxDistance = distance
farthest = target
# Take out the farthest enemy!
# Keep attacking the enemy while its health is greater than 0.
Are you sure that is the code?
Sand snakes look like this.
whoops wrong code sorry let me repost it
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
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.
Just indent everything by 1 from
coins = hero.findItems() to
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.