Backwoods Brawl level 5

My code is below. How should I improve it? I’m already on level 5 in Backwoods Brawl and I have 2514 health.

while True:
    enemy = hero.findNearestEnemy()
    enemies = hero.findEnemies()
    l=1
    health = []
    for enemy in enemies:
        l+=1
        health[l] = enemy.health
    strongest = max(health)
    for enemy in enemies:
        if enemy.health==strongest:
            if hero.canCast("chain-lightning", enemy):
                hero.cast("chain-lightning", enemy)
                hero.shield()
            else:
                hero.attack(enemy)
                hero.shield()
1 Like

If you want to shield, it’s better not to attack. If you want to attack, it’s better not to shield. LOL

3 Likes

Ok, so, the strongest is an enemy at max health, but that isn’t even how you do it. If I were you, I’d just attack any old enemy, do a while enemy.health > 0, and then attack. Chain-lightning works fine. you might want to do a find strongest enemy by:

def findStrongestEnemy
    enemies = hero.findEnemies (and then iterate through all the enemies to get the enemy with the most health(are you in cloudrip).).

You can just do

maxHealth = 0
if enemy.health > maxHealth