Clash Of Clones Python Help Please

hero.moveXY(63, 68)
while True:
    enemy = hero.findNearestEnemy()
    if enemy and enemy.type != "sand-yak":
        if hero.isReady("bash"):
            hero.bash(enemy)
        elif hero.isReady("cleave") and hero.distanceTo(enemy) < 10:
            hero.cleave(enemy)
        elif hero.distanceTo(enemy) < 15:
            hero.attack(enemy)
        else:
            hero.moveXY(68, 39)
            enemy = hero.findNearestEnemy()
            if enemy and enemy.type != "sand-yak":
                if hero.isReady("bash"):
                    hero.bash(enemy)
                elif hero.isReady("cleave") and hero.distanceTo(enemy) < 10:
                    hero.cleave(enemy)
                else:
                    hero.attack(enemy)
            else:
                hero.moveXY(104, 50)
                enemy = hero.findNearestEnemy()
                if enemy and enemy.type != "sand-yak":
                    if hero.isReady("bash"):
                        hero.bash(enemy)
                    elif hero.isReady("cleave") and hero.distanceTo(enemy) < 10:
                        hero.cleave(enemy)
                    elif hero.distanceTo(enemy) < 15:
                        hero.attack(enemy)
                    else:
                       continue

this is my code i need help it aint working

Hey there! Could you elaborate on the problem?
For example what happens when you run the code?
When does it stop working? Or possible errors that’re shown?

EDIT:
after testing the code myself, it seems to be working, so I’d guess the problem’s simply on how to tackle this level. If i am not mistaken I had those gloves that give access to the chain-lightning spell and used it whenever it was ready on the closest enemy.
You could try to focus the archers first though and after that, once all your soldiers’re dead, try to kite(lure) the enemy around your archers so that the enemy hero attacks less, moves more and your archers are able to shoot at him.

There’re probably quite a lot of possibilities to tackle this level so let your imagination run free :grinning:
Another idea would be to look if you can get an upgrade to your equipment (new items) that give access to more/new spells!

I agree with @Shurutsue, your code is working. Below is some advice I’ve given before on this level.

Bon, here’s how I did it with the dark brown lady (different heroes will need different codes):

Use Flags
Don’t Equip Strong Weapons, the heavier you weapon the easier your boys get crushed.
Make your health as low as you can so you’ll defeat the clone faster. Just avoid getting hit.
Kill with Chain Lightning, you can buy a certain glove I think. This does 120 damage.

Wait for your boys to kill the rest. Wobble around avoiding the arrows. Attack right after picking up the flag.

Please don’t post solutions. It goes against our community guidelines.

Hey Luke10! :wave:
The rules regarding solutions for this discourse are actually located here, if I’m not mistaken. :stuck_out_tongue:
Second: In case advice, or information on how one solved it himself (without actual code) is considered an actual solution, please also flag my post further above(or let me know so i will flag it myself), as i did more or less the same, thank you. :sweat_smile:

1 Like

Hey @Shurutsue thanks for the advice!
I looked at the link you posted and the only mention about posting solutions that Chaboi gave was this:

“You may not post solutions. It is strongly against the rule and might result in a mute or ban”

The reason why I flagged MonsterbyMistake’s post is because he said, "This is how I did it
Then he put:

This is a form of a solution. He is not giving a code solution, but he is communicating on how to solve it. What I mean by how is the direct steps on how to solve this level.

I hope you don’t take any offense to this explanation and I once again commend you for your concern!!!

Edit: Also regarding your statement:

You are right

@MonsterByMistake’s post doesn’t strike me as a solution. He isn’t posting completed code to a challenge, they are just suggestions for completing the level. Even with those hints there are still a lot of steps that need to be taken before you can arrive at the solution.

That’s true… Thanks @Narishm!

@MonsterByMistake can you confirm that? I just want to make sure that isn’t a solution

You are welcome! :slight_smile:

1 Like

Bon without debating too intensely…if you believe figuring levels out is an essential part of coding and no spoiler can be given, delete the post. I don’t mind at all.
But if you think CodeCombat is just a way to help you understand code concepts, and solving puzzles aren’t important for this purpose, it makes sense to leave it here, for those who need to move on.

Cheers,

I think you misunderstand. Are you posting a solution or are you just giving little hints?

hints

[en_US.composer.my_button_text]

Oh ok. Thanks for confirming…

This is a solution with knight. I think I found an easier way to play beat this level after many trails and errors. Trick is to equip your hero with the highest level armor and use the sword with cleave, or a low damage weapon. (maybe not even)

I find that if you prioritize your target with archers first, then scout, then ogre, then clone hero; you will soak up the damage behind the enemy line (since they always target closest). Then you proceed to still be a tank and have your archers wipe out everything else.

while the clone hero will have lots of armor, I find that since your weapon is low damage, the clone can’t hurt your side too much and will eventually die from arrows.

My solution was less than 30 lines!

OK ur banned, i found a hack and now im a moderator

jk LOL

No solutions!!!

Let’s keep it civil. And Speedypickle1 is not banned, neither are you a moderator.
Danny

can you ban people? (20)

No. And it’s never been used since I’ve been on the forum (that I’m aware of). Mostly it’s just limited time mutes.
Danny