"Mad Maxer" help ;-;


#1

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)

#2

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.


#3

Okay. Thank you for the help!


#4

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


#5

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


#6

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


#7

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


#8

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.


#9

Thank you so much dude!