Diamond dozen (Help)


#1
# Claim the coins while defeating the marauding ogres.
# If you defeat the ogre with the most health, the rest of the ogres will run!
# Coins vanish quickly after appearing, so be sure to find the best value!

def findMostHealth(enemies):
    target = None
    targetHealth = 0
    enemyIndex = 0
    while enemyIndex < len(enemies):
        enemy = enemies[enemyIndex]
        if enemy.health > targetHealth:
            target = enemy
            targetHealth = enemy.health
        enemyIndex += 1
    return target

# Make a function named findOptimalCoin which returns the coin with the best value.
def findOptimalCoin(coins):
    optimal = -1000
    thione = None
    for coin in coins:
        if coin.value / self.distanceTo(coin) > optimal:
            optimal = coin.value / self.distanceTo(coin)
            thione = coin
    return thione
# Coins rapidly appear and disappear, so pick the best coin.
# Optimize your path by going for the coin with the largest value over distance.
while True:
    enemies = hero.findEnemies()
    enemy = findMostHealth(enemies)
    if enemy and enemy.health > 15:
        while enemy.health > 0:
            hero.attack(enemy)
    else:
        coins = hero.findItems()
        coin = findOptimalCoin(coins)
        if coin:
            hero.moveXY(coin.pos.x, coin.pos.y)


#2

What is wrong with my code?


#3


#4

To Be Honest Their Is Nothing Wrong With Your Code I Read It And Then Used It On The Same Level And It Said Success.


#5

Then it could be an equipment issue?


#6

What equipment should I use?


#7

Post a screenshot of what you are wearing, that way we can tell


#8

Okay I will do that now.


#9


#10

This is it. :slightly_smiling_face:


#11

you know, this should work. I tried this level with the same equipment and it worked.


#12

Try Using Boots Of Leaping And If That Doesn’t Work Try Contacting @Nick.


#13

Gotcha. @Wealthy-Boss


#14

Nick won’t respond. :no_mouth:


#15

@Wealthy-Boss What equipment are you using.


#16

Nevermind it was a bug. When i clicked submit it worked.:smiley: