# Mad maxer - why is it not working?

My code is currently working to kill the enemy that is the farthest first, but the hero died at the second wave of enemy. Is it because my hero is too weak? What should I have for this level then? Can anyone helps me?

Thank you! O(∩_∩)O

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 = 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:
if farthest.health>0:
self.attack(farthest)``````

ive had problems with life too. try to use best armor and Weapon. In my case weapon was the important

first off, you didn’t do what the instructions said to do…

“Keep attacking the enemy while its health is greater than 0.”

``````if farthest:
if farthest.health>0:
self.attack(farthest)
``````

This only attacks the farthest enemy once, and as such is no different from:

``````if farthest:
self.attack(farthest)
``````

(which would switch from the ranged attackers to the furthest whatever attacker.)

You need to use a loop of some sort there . . . (look at your Programmaticon III for help on how to use a “while-loop”, if you don’t remember)

I’m stuck on this level too.
My code makes the character attack and kill the furthest enemies first but he doesn’t have enough health to defeat them all. And I don’t have enough gems to buy better equipment.

Maybe there is a more efficient strategy rather than killing the furthest enemies first. Is it possible to find the dps of each enemy?

Try to Buy the long Ranged Sword… Then attacking the furthest is more easy

While I don’t think so, you can assume that the more `maxHealth` someone has, the higher there damage is. Throwers and Shamans drop a bit out of this, and should always be targeted first, as they deal a huge amount of damage over time.
Depending on your gear it is usually enough to land one hit on them. However your cleave is not strong enough for killing any of the two, so you can use it anytime you want. I usually count the amount of enemies around me and only cleave if there are 4 or more enemies (depending on type), as 3 munchkins simply are not a threat to me anymore. I can as well kill them by hand.

More than a better sword I can recommend a good shield to buy. A shield gives you HP, a higher damage-block rate when actively shielding and (in most cases) a fairly strong bash-attack, which takes a really short time to perform (the greatsword takes 1 second to attack!), and has a fairly low cooldown.

1 Like

I actually managed to beat the level by altering my strategy very slightly.
I believe the main purpose of the level is to write code that makes you attack the furthest enemies first, i.e. the ones with the highest dps. Previously, I kept dying at the start of the third wave because my character would take too much damage moving towards the furthest enemies.

So I tried manually moving my character to where I thought the ranged enemies would appear in the next wave. Although this caused my character to briefly not attack the ranged enemy first since it was no longer the furthest, the strategy worked and it slightly reduced damage taken and I was able to defeat the third (final) wave very narrowly.

Hahah, funny story, I played through up to a character level of 21 with just the long sword (because I find cleave so much more interesting than the other sword effects). But mad-maxer forbids the long sword, so all I had left to work with is the starting sword, which is so weak that I can’t win with it.

Um, yeah, I tried that . . . I estimate it would take over 3100 hp to do it with the simple sword. It looks like a fully tricked out Anya/Tharin can (currently) get to 3680. So it might actually, be doable…

###### (601+1142+125+5+5 + 751 = 2629 * 1.4 = 3680.6)
1 Like

whoops . anyways I used a strong sword like kith steel blade and had 907 health