Mad Maxer in Desert

I’ve tried many code on this topic, but nothing works, I use Javascript and Python.

The problem was that I kept banging my head to the wall, it automatically goes right for some reasons, it won’t even bother me when I ask him to attack the enemies.

Can someone tell me whats going on? Do I have to post my code here for you guys to review and help out? Cause no matter which type of code language I use, Python or Javascript, its still doing the same thing.

Or can someone send me their code and explain to me how did you do it.

Thank you very much for helping if you can.

Hello, Winding_Phoenix, and welcome.

Please, please post your code! The purpose of this forum is to help people like you out. We don’t usually give out working code, as it provides an easy answer while preventing the user from learning. Post your code, and use radiant, harmonious formatting according to the FAQ.

I fixed my code again, but after I took down the first wave. My hero won’t attack the second wave, can you fix my code?

Kill the enemy that’s farthest away first.

loop:
farthest = None
maxDistance = 0
enemyIndex = 0
enemies = self.findEnemies()

# Look at all the enemies to figure out which one is farthest away.
while enemyIndex < len(enemies):
    target = enemies[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

if farthest:
    # Take out the farthest enemy!
    # Keep attacking the enemy while its health is greater than 0.
    pass
while farthest.health > 0:
    if self.isReady("power-up"):
        self.powerUp()
    else:
        self.attack(farthest)

Thanks!

Health = 1084
Sword = Simple Katana

If your hero does not attack because of an error, you might want to check your indentation of

while farthest.health > 0:

Seems to me it’s not indented properly. (Though I can’t tell for sure, because you didn’t use “radiant, harmonious formatting” when posting your code.)

If your hero doesn’t have an error, then I’m not sure what the problem is.

Kill the enemy that’s farthest away first.

loop:
farthest = None
maxDistance = 0
enemyIndex = 0
enemies = self.findEnemies()

# Look at all the enemies to figure out which one is farthest away.
while enemyIndex < len(enemies):
    target = enemies[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

if farthest:
    # Take out the farthest enemy!
    # Keep attacking the enemy while its health is greater than 0.
    pass
    while farthest.health > 0:
    if self.isReady("power-up"):
        self.powerUp()
    else:
        self.attack(farthest)

I fixed the indentation, but it says "Hard Execution Limit of 3000000 exceeded.

Your indentation inside the while loop is probably wrong.

(And the reason for the execution limit reached is due to some bug (?) that, if you don’t do anything inside a while loop, it infinite loops, resulting in the hard execution limit being reached.)

A hard execution limit is when an non CC(loop) infinite loop happens such as

while(1 === 1){
   this.say("1 = 1 yay!")
}

Basically anything that will not break