Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Алмазная дюжина


Скажите пожалуйста, что не так с кодом?

Собирай монеты, разгоняя мародёрствующих огров.

def findMostHealth(enemies):
    target = None
    targetHealth = 0
    enemyIndex = 0
    while enemy

Index < len(enemies):
        enemy = enemies[enemyIndex]
        if > targetHealth:
            target = enemy
            targetHealth =
        enemyIndex += 1
    return target

def valueOverDistance(items):
    return item.value / hero.distanceTo(item)

# Возврати предмет с наибольшим значением `valueOverDistance(item)`.
def findBestItem(items):
    bestItem = None
    bestValue = 0
    itemsIndex = 0
    # Перебери массив предметов.
    # Найди предмет с наибольшим значением `valueOverDistance()`.
    if itemsIndex < len(items):
        item = items[itemsIndex]
        if valueOverDistance(items) > bestValue:
            bestValue = valueOverDistance(items)
            bestItem = item
        itemsIndex += 1
    return bestItem

while True:
    enemies = hero.findEnemies()
    enemy = findMostHealth(enemies)
    if enemy and > 15:
        while > 0:
        coins = hero.findItems()
        coin = None
        coin = findBestItem(coins)
        if coin:
            hero.moveXY(coin.pos.x, coin.pos.y)

Please learn to post your code correctly. The way it is now, we can’t see the structure. Help us help you. It’s very easy to do and just takes a tiny bit of effort. Please read this topic and format your code again correctly


Thank you. I changed this post.