"Mad Maxer" help ;-;

Hello, I’ve been stuck on this code for a while now, I kill the first person but then he just stands still. I would appreciate your help xD
Code:

farthest = None
maxDistance = 0
enemyIndex = 0
enemies = self.findEnemies()
while enemyIndex < len(enemies):
    target = enemies[enemyIndex]
    enemyIndex = enemyIndex+1
    # Is this enemy farther than the farthest we've seen so far?
    distance = self.distanceTo(target)
    if distance > maxDistance:
        maxDistance = distance
        farthest = target
loop:
    if farthest:
        self.attack(farthest)

Your variables on top are only defined once. It would be better to place the entire program in a loop, instead of just the last two lines.

Okay. Thank you for the help!

Haha… Now I die halfway through, I cant do any other levels to get gems and get more health .-.

What do you mean by that? That you’ve done all the other levels or that you can’t do some of them?

i think this should be closed.
you can use the search Funktion in the upper right corner, there should be sth about 3 or 4 Posts of Mad Maxer in this forum. Problem with life is often the case.

Close - doublepost

Yes, I do not have enough health to finish the level, I die halfway through and I cant get gems because I have beaten all other levels, so now I have to do the daily quiz and get gems that way haha

Well, in that case, go here: http://codecombat.com/play/ladder/dueling-grounds#simulate. You can simulate games that way, earning you 20x^0.4 gems, where x is the number of games you have simulated. You should get a few hundred pretty quickly.

1 Like

Thank you so much dude!