Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Sarven Desert - Mad Maxer - Too much default code. Too easy


I only had to write 2 lines of code to win this one and missed out on learning how to do it myself.

I only added this inside the “if (farthest)” block and won…

 while ( > 0){

Here is the stock… winning code:

// Kill the enemy that's farthest away first.

loop {
    var farthest = null;
    var maxDistance = 0;
    var enemyIndex = 0;
    var enemies = this.findEnemies();

    // Look at all the enemies to figure out which one is farthest away.
    while (enemyIndex < enemies.length) {
        var target = enemies[enemyIndex];
        enemyIndex += 1;

        // Is this enemy farther than the farthest we've seen so far?
        var distance = this.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.


And yet there are seven different threads about this level…


I think the ease of this level is intended, because it introduces a new concept. For the first time you have to loop through all enemies to check for the property you’re looking for (distance in that case). And it’s used time and time again in the next MadMaxer levels (subscriber only), to look for healthiest or find the best coin -not the nearest- around you. It’s the first time a player is actually opening the black box that is “findNearestEnemy”.

Later in the mountain, many times you’ll have to use smart functions to decide what to do with which unit (Librarian tactics comes to mind, to learn how to focus fire). I was rather happy to copy paste this code as a well formated structure for the many more similar functions I wrote later in the game. Even though that made this level too easy.

PS : I had trouble with my warrior on this particular level. Are you playing a warrior ? My stuff wasn’t complete because I only bought the best armor / weapon (at the time, I only had the best shield, the best weapon and ring on speed, so no armor or helmet other than the bronze ones). And due to the low cost effectiveness, I struggled a bit : with this stuff, the level isn’t 2 lines of code ^^.


This is similar to Vital powers because this level intros a new concept
Vital powers functions
Mad Maxer Arrays