I need help on clash of clones plz

Here’s 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.

self.moveXY(68, 78)
back = 0
while True:
    enemys = self.findEnemies()
    index = 0
    closest_soldier = None
    soldier_dist = 999
    closest_archer = None
    archer_dist = 999
    closest = None
    dist = 999
        distance = self.distanceTo(enemys[index])
        if(enemys[index].health>0 and enemys[index].type != "sand-yak" ):
            if(enemys[index].type == 'archer' and distance<archer_dist):
                closest_archer = enemys[index]
            if(enemys[index].type == 'soldier' and distance<soldier_dist):
                closest_soldier = enemys[index]
                closest = enemys[index]
        index +=1
    if(closest_soldier and soldier_dist<10):
        enemy = closest_soldier
    elif(closest_archer and archer_dist<20):
        enemy = closest_archer
        enemy = closest
        if(self.health<self.maxHealth/2.5 and back==0):
            self.moveXY(40, 85)
            back = 1
        elif(self.health<self.maxHealth/5 and back==1):
            self.moveXY(40, 85)
            back = 2
        elif(self.isReady("jump") and self.distanceTo>15):

Here’s my equipment:

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review this topic, which shows all essentials of this board! Thanks!

This code doesn’t seem to match your character. I would encourage you to restart the level and write code that fits your hero and their gear. I see you have the Scaled gloves and Steel Ring, but I don’t see your code to use them. Also, the sword you have selected does not have the cleave or powerUp abilities, and the boots don’t have the jump ability. We are more than happy to help you complete this level, but we also want to make sure you are learning the core concepts of coding while being able to problem solve with creative solutions.

Would you recommend a sword that has both cleave and powerUp as an ability?

There is no sword which has both the powerUp and cleave abilities. You’ll have to chose one or the other. I would recommend the basic cleave sword you get in the forest (you will have it if you’re in the desert). And, as Brooksy said, you could use the scaled gloves to gain an advantage. I’m sure you know this, but the clone can’t use abilities, so you must focus on gaining an advantage there. You’ve got a bash sword which is good. You have to make sure you maximise the damage you can with cleave. Maybe jump into a good position where you’re surrounded by troops, then cleave?

I don’t really know how to implement that into my code, could you give me an example??

It could be something very simple. e.g.

hero.jumpTo({"x": exampleX, "y": exampleY})
while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        # use your abilities

I find a section before a while True loop which only happens once at the start is a very useful tactical tool.

1 Like

I suggest you write your own code because I found the exact same code on Github.
Taking other peoples’ code often doesn’t work because their heroes/equipment is different, so it’s a better bet to write your own.