[Solved] Clash of clones python

hello I would like some help with solving Clash of Clones no matter what I do I die.
here is my equipment
Screenshot 2020-05-07 at 16.25.11
and my code

    enemies = hero.findEnemies()
    strongest = None
    greatestHealth = 0
    enemyIndex = 0
    for enemy in enemies:
        if enemy.health > greatestHealth:
            if enemy.type != "sand-yak":
                strongest = enemy
                greatestHealth = enemy.health
    return strongest

def findWeakestEnemy():
    enemies = hero.findEnemies()
    weakest = None
    leastHealth = 99999
    enemyIndex = 0
    for enemy in enemies:
        if enemy.type != "sand-yak":
            if enemy.health < leastHealth:
                weakest = enemy
                leastHealth = enemy.health
        return weakest

while True:
    #weakestShaman = findWeakestEnemy()
    hero.maxSpeed == 10
    strongestShaman = findWeakestEnemy()
    if strongestShaman:
        hero.attack(strongestShaman)
        if hero.isReady("cleave"):
            hero.cleave(strongestShaman)
        if hero.isReady("bash"):
            hero.bash(strongestShaman)
        if hero.health < hero.maxHealth / 2:
            if hero.isReady("shield"):
                hero.shield()
            #strongXY = (strongestShaman.pos.x, strongestShaman.pos.y)
            #hero.moveXY(29, 99)
        if hero.health < hero.maxHealth / 4:
            hero.moveXY(51, 44)
    if strongestShaman.type == "ogre":

I donā€™t know what is wrong and what to do to fix it my character kills for a while then dies.

I canā€™t get the emperorā€™s gloves for a while.

Hi, you seem to be missing some code. Please could you post all of your code.
Also what is this bit:

You canā€™t define your heroā€™s max speed.
Danny

I have nothing past the if enemy.type == ā€œogreā€
and that was a hopeful thing

image

WTH is this?

I got the amber sense stone for 2100 gems and it sux
btw idk how i got it cuz it is a level 66 item

Why didnā€™t you get the worn dragon helm? it have about 150 more health than obsidian and it only costs 200 gems more than engraved obsidian helm, if you had less than 1900 gems that time, you should stay with softened leather boots and use the extra gems to buy the dragon helm

I canā€™t and I need gems as well. I am stuck there after completing all other levels that I can.

i have about the same armor as u, and it said sucess, but when i submit, i died. Maybe the seed is bad.

Do something simple, not so complicated.
move forward to a position like x:82 y:79 and target the nearest enemy so you will kill all archers, because they do most dmg, after that, it will be easy.
Your shield does 30 dmg, which is enough to kill at least 1 archer.

Thanks I will try that and respond with the end result

retreat after you kill 2/3 archers because you might die in the process of doing so as they do great damage, soldiers can do the rest. Get the wooden strand so you can regen while retreating.

oh, u do have the strand, nvm

thanks I beat the level your advice about killing the archers and making my code less complicated helped a lot!

Your welcome, good luck in the mountains!

I canā€™t beat this level whatā€™s wrong with my code?

# You'll need good strategy to win this one!
# Your clone will have the same equipment you have!
# But, they're not very skilled at using special powers.
def findWeakestEnemy():
    enemies = hero.findEnemies()
    weakest = None
    leastHealth = 99999
    enemyIndex = 0
    # Picking out individual enemy from the array and testing his health agains leastHealth
    while True:
        enemy = enemies[enemyIndex]
        if enemy.health < leastHealth:
            weakest = enemy
            leastHealth = enemy.health
            enemyIndex += 1
            return


while True:
    enemy = findWeakestEnemy()
    if enemy:
        hero.attack(enemy)


Return what? Has to be

return True(whatever you want to return)

also read up his advice about the move over to the archers and kill them helps a lot because the archers do a lot of damage. with leastHealth = 9999 no one will have more health than that so drop that number by a huge amount.

The strategies you guys are using are great, but personally I think it over complicates the solution. I was able to beat the level using only 3 lines of code and it will work with any armor.

same i did that too!

Hello, is there something wrong in my code or my character is too weak please check out the codeā€¦Thank you! My character is Alejandro and has 1503 life.

# The function find the weakest enemy.
def findWeakestEnemy():
    enemies = hero.findEnemies()
    weakest = None
    leastHealth = 99999
    enemyIndex = 0
    # Loop through enemies:
    for enemy in enemies:
        # If an enemy's health is less than least health:
        if enemy.health<leastHealth:
            # Make it the weakest
            weakest=enemy
            # and set leastHealth to its health
            leastHealth=enemy.health
        return weakest

while True:
    # Find the weakest enemy with the function:
    weakestShaman = findWeakestEnemy()
    # If the weakest enemy here:
    if weakestShaman:
        # Attack it!
        
        
        hero.attack(weakestShaman)