Finding the strongest enemy

Hi, I am doing Backwoods Brawl 4 I’ve tried many codes but none of them worked. Now I want to find the strongest enemy and attack it. I have 2514 health and here is my current code:

while True:
    enemy = hero.findNearestEnemy()
    enemies = hero.findEnemies()
    l=1
    health = []
    for enemy in enemies:
        l+=1
        health[l] = enemy.health
    strongest = 
    hero.attack(strongest)

How do you find strongest?

You can try it this way.

while True:
    enemies = hero.findEnemies()
    strongest = 0
    bestHealth = 0
    for enemy in enemies:
        if enemy.health > bestHealth:
            bestHealth = enemy.health
            strongest = enemy
    if strongest:
        hero.attack(strongest)

This will iterate over all enemies, and get the strongest enemy, and attack it.

4 Likes

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