# Clash of Clones help

**URL:** <https://discourse.codecombat.com/t/clash-of-clones-help/6347>\
**Category:** Uncategorized\
**Created:** [January 5, 2016, 12:46am UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347 "2016-01-05T00:46:54Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Steven\_Kang2003](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@Steven\_Kang2003](https://discourse.codecombat.com/u/Steven_Kang2003)\
**Post date:** [January 21, 2016, 7:47pm UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347/23 "2016-01-21T19:47:48Z")

</div>

did they name clash of clones after clash of clans?😀

---

<div class="post-metadata">

**Author:** ![Neel\_Sharma](https://avatars.discourse-cdn.com/v4/letter/n/e495f1/32.png) [@Neel\_Sharma](https://discourse.codecombat.com/u/Neel_Sharma)\
**Post date:** [January 31, 2016, 5:09pm UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347/24 "2016-01-31T17:09:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michael\_Frankah](https://avatars.discourse-cdn.com/v4/letter/m/74df32/32.png) [@Michael\_Frankah](https://discourse.codecombat.com/u/Michael_Frankah)\
**Post date:** [February 16, 2016, 6:35pm UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347/25 "2016-02-16T18:35:21Z")

</div>

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:

```python
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)

```

 ![](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/4/40385b17d6107be2f4874cdb2d2374b09686ebb3.png)

---

<div class="post-metadata">

**Author:** ![ChronistGilver](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chronistgilver/32/3778_2.png) [@ChronistGilver](https://discourse.codecombat.com/u/ChronistGilver)\
**Post date:** [February 16, 2016, 11:49pm UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347/26 "2016-02-16T23:49:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![AdrianCgw](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@AdrianCgw](https://discourse.codecombat.com/u/AdrianCgw)\
**Post date:** [February 17, 2016, 1:28am UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347/27 "2016-02-17T01:28:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![isidiotic](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/isidiotic/32/3831_2.png) [@isidiotic](https://discourse.codecombat.com/u/isidiotic)\
**Post date:** [February 17, 2016, 11:56pm UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347/28 "2016-02-17T23:56:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Neel\_Sharma](https://avatars.discourse-cdn.com/v4/letter/n/e495f1/32.png) [@Neel\_Sharma](https://discourse.codecombat.com/u/Neel_Sharma)\
**Post date:** [February 23, 2016, 2:39am UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347/29 "2016-02-23T02:39:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Neel\_Sharma](https://avatars.discourse-cdn.com/v4/letter/n/e495f1/32.png) [@Neel\_Sharma](https://discourse.codecombat.com/u/Neel_Sharma)\
**Post date:** [February 23, 2016, 2:41am UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347/30 "2016-02-23T02:41:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Neel\_Sharma](https://avatars.discourse-cdn.com/v4/letter/n/e495f1/32.png) [@Neel\_Sharma](https://discourse.codecombat.com/u/Neel_Sharma)\
**Post date:** [February 23, 2016, 2:43am UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347/31 "2016-02-23T02:43:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![isidiotic](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/isidiotic/32/3831_2.png) [@isidiotic](https://discourse.codecombat.com/u/isidiotic)\
**Post date:** [February 23, 2016, 9:55pm UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347/32 "2016-02-23T21:55:25Z")

</div>

Well I still won anyways.

---

<div class="post-metadata">

**Author:** ![Debash](https://avatars.discourse-cdn.com/v4/letter/d/b5e925/32.png) [@Debash](https://discourse.codecombat.com/u/Debash)\
**Post date:** [March 23, 2016, 12:51pm UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347/34 "2016-03-23T12:51:50Z")

</div>

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

[redacted, please don’t post solutions]

---

<div class="post-metadata">

**Author:** ![Neel\_Sharma](https://avatars.discourse-cdn.com/v4/letter/n/e495f1/32.png) [@Neel\_Sharma](https://discourse.codecombat.com/u/Neel_Sharma)\
**Post date:** [March 23, 2016, 1:31pm UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347/35 "2016-03-23T13:31:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Debash](https://avatars.discourse-cdn.com/v4/letter/d/b5e925/32.png) [@Debash](https://discourse.codecombat.com/u/Debash)\
**Post date:** [March 23, 2016, 1:47pm UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347/36 "2016-03-23T13:47:53Z")

</div>

Yes it works. Tested 😉

---

<div class="post-metadata">

**Author:** ![Neel\_Sharma](https://avatars.discourse-cdn.com/v4/letter/n/e495f1/32.png) [@Neel\_Sharma](https://discourse.codecombat.com/u/Neel_Sharma)\
**Post date:** [July 27, 2016, 1:03pm UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347/37 "2016-07-27T13:03:55Z")

</div>

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:

```python
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);
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![George\_Huchins\_Hun](https://avatars.discourse-cdn.com/v4/letter/g/6de8d8/32.png) [@George\_Huchins\_Hun](https://discourse.codecombat.com/u/George_Huchins_Hun)\
**Post date:** [February 27, 2017, 12:07am UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347/38 "2017-02-27T00:07:21Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![Caleb\_Soo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/caleb_soo/32/6802_2.png) [@Caleb\_Soo](https://discourse.codecombat.com/u/Caleb_Soo)\
**Post date:** [July 29, 2017, 2:16pm UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347/39 "2017-07-29T14:16:42Z")

</div>

do you know the fact that there are sand yaks?  
 ![image](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex016/uploads/codecombat/original/2X/1/19d469b385db73a936fac99334e46c4917f6edb0.png)

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

result:  
 ![image](https://cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex016/uploads/codecombat/original/2X/8/8a6dc533397b073fe4b7f90c520d53e52c578ace.jpg)

how do I ignore the sand Yaks?

thanks

---

<div class="post-metadata">

**Author:** ![Caleb\_Soo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/caleb_soo/32/6802_2.png) [@Caleb\_Soo](https://discourse.codecombat.com/u/Caleb_Soo)\
**Post date:** [July 29, 2017, 2:17pm UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347/40 "2017-07-29T14:17:40Z")

</div>

Do I have to return false or something?

---

<div class="post-metadata">

**Author:** ![Caleb\_Soo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/caleb_soo/32/6802_2.png) [@Caleb\_Soo](https://discourse.codecombat.com/u/Caleb_Soo)\
**Post date:** [July 29, 2017, 2:19pm UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347/41 "2017-07-29T14:19:37Z")

</div>

my code:(so far)

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

---

<div class="post-metadata">

**Author:** ![Hellenar](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/hellenar/32/9100_2.png) [@Hellenar](https://discourse.codecombat.com/u/Hellenar)\
**Post date:** [July 30, 2017, 12:58am UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347/42 "2017-07-30T00:58:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Caleb\_Soo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/caleb_soo/32/6802_2.png) [@Caleb\_Soo](https://discourse.codecombat.com/u/Caleb_Soo)\
**Post date:** [July 30, 2017, 10:30am UTC](https://discourse.codecombat.com/t/clash-of-clones-help/6347/43 "2017-07-30T10:30:34Z")

</div>

thanks! it worked! 😄

[Previous page](https://discourse.codecombat.com/t/clash-of-clones-help/6347.md?page=1)

[Next page](https://discourse.codecombat.com/t/clash-of-clones-help/6347.md?page=3)
