{SOLVED}Vital Powers Python help!


Code:

# Этом уровень покажет, как определять собственные функции.
# Код внутри функции не выполняется сразу. Он сохраняется для последующего использования
# Эта функция заставляет вашего героя поднять ближайшую монету.
def pickUpNearestCoin():
    items = self.findItems()
    nearestCoin = self.findNearest(items)
    if nearestCoin:
        self.move(nearestCoin.pos)

# С помощью этой функции ваш герой призывает солдата.
def summonSoldier():
    # Размести здесь код, призывающий солдата, если у тебя достаточно золота.
    if self.gold >= self.costOf("soldier"):
        self.summon("soldier")
    pass


# Эта функция приказывает вашим солдатам атаковать ближайшего врага.
def commandSoldiers():
    for soldier in self.findFriends():
        enemy = soldier.findNearestEnemy()
        if enemy:
            self.command(soldier, "attack", enemy)

while True:
    # В своем цикле ты можешь "вызывать" функции, определенные выше.
    # Эта строка вызывает выполнение кода внутри функции "pickUpNearestCoin" .
    pickUpNearestCoin()
    enemy = self.findNearest(self.findEnemies())
    if enemy and self.distanceTo(enemy) <= self.attackRange:
        self.attack(enemy)
    # Вызови summonSoldier  здесь.
    summonSoldier()
    # Вызови commandSoldiers  здесь.
    commandSoldiers()

I keep on failing and I don’t know why. Please help.

Remove this near the bottom of the code. The problem is your hero can’t collect enough coins because they’re fighting too much instead of collecting coins. Soldiers fight, Heroes collect :slight_smile:

Hope this helps,

Marmite

When, i do that, I still don’t collect at least 125 gold. I only get 90. Any other suggestions.

Hm… I’m guessing that that’s your best armour, and that shouldn’t be a problem… Despite the fact that the hints and comments don’t tell you to, try using a “find best value” calculator instead of finding the nearest coin.

Ok, sorry. I’ve got to go. I’ll be active again in 15 hours… (Parental Controls :grimacing:)

I just bought a better helmet. Let me rerun and then i’ll report again

Okay. I beat it. This is no longer needed.

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.