Clash of Clones help

did they name clash of clones after clash of clans?:grinning:

no idea whatsoever.
but for one, I play clash of clans too

Hello ChronistGilver,
I a bit stuck with the clash of clones level. I used the following code but i only have a crude spike sheild and 220 coins is there anyway you can help me please. Thanks in advance for your time.

My code:

loop:
    enemyIndex = 0
    enemies = self.findEnemies()
    while enemyIndex < len(enemies) and self.health > self.maxHealth / 4:
        enemy = enemies[enemyIndex]
        enemyIndex += 1
        if enemy.type != 'sand-yak':
          while enemy.health > 0:
            if self.isReady("cleave"):
                    self.cleave(enemy)
             else: 
                 self.attack(enemy)
    if self.health <= self.maxHealth / 4:
        enemy = enemies[enemyIndex]
        distance = self.distanceTo(enemy)
        enemyIndex += 1
        if distance > 2:
           if self.isReady("cleave"):
                                 self.cleave(enemy)
            else:
                self.attack(enemy)

Hello, Michael, and welcome. Please read the FAQ before you post again. It is essential that you learn how to format your code properly. I’ve done it for you this time.

I notice that you don’t use the bash attack, even though you have a shield with this ability. Perhaps consider adding that in.

In this level the Simple CPU has the same equipment as you. To win have to right better code.

  • use powers (you already doing this)
  • smart targeting: attack the best target.

Try to target: enemy hero (enemy.id==“Hero Placeholder 1”) or archers (enemy.type==“archer”), the nearest archer

Doing a cleave on any archer is also good. Doing a cleave on enemy hero is bad because the cleave has worse single target damage output than the normal attack

This is my strategy, I will not spew out all the code.

I find my nearest enemy, then if there is an enemy that is not a sand yak, I attack it. Once my health is lower than 50, I shield once and go someplace away from the battle, then my archers will destroy the rest of the clones.

The best way to defeat this level is through just using abilities like bash or throw because the Simple CPU does not use abilities. If you use any other method than abilities with OP gear than you will loose. If you use bash or throw with an attack you probably will win if you have horrible gear. If you use OP gear then just use abilities. If not, use abilities and attack and you should win.

Just remember not to attack sand yaks and make sure your if statements are right

Also, the point here is that you use abilities. Since you put in the code to attack, the opponent will attack too.

Well I still won anyways.

Hello. I first killed all the archers, and then all the rest

[redacted, please don’t post solutions]

Well, they do the most damage so it should work.

Yes it works. Tested :wink:

Hi guys, I’m back I am using a new account that I play using Javascript and I’m stuck on clash of clones. There are no bugs in my code but I’m not able to defeat the level. Any suggestions? Here is my code:

while(true) {
    var enemy = hero.findNearest(hero.findEnemies());
    var flag = hero.findFlag();
    if (flag) {
        hero.pickUpFlag(flag);
    }
    if (enemy && enemy.type != "sand-yak") {
        if (hero.isReady("power-up")) {
            hero.powerUp();
        } else if (hero.isReady("bash")){
            hero.bash(enemy);
        } else {
            hero.attack(enemy);
        }
    }
}

@ChronistGilver What do you think would happen when you don’t equip a weapon? Remember that the clone has the exact same gear as you do.

it will not let you go into the level if you unequip the sword

do you know the fact that there are sand yaks?
image

My hero, after he has killed my clone, and defeated some of the ogres, he attacks the sand yaks.

result:
image

how do I ignore the sand Yaks?

thanks

Do I have to return false or something?

my code:(so far)

while True:
enemy = hero.findNearestEnemy()
if enemy.type == ‘soldier’ or ‘archer’ or ‘hattori’:
hero.attackDamage
hero.attack(enemy)

Just try if enemy.type != "sand-yak":

1 Like

thanks! it worked! :smile: