Summit's Gate. Again. Errors =]


#1

Hi. I got this error


it’s say that I choose wrong unit.

but I select friends and give it to function

 var friends = hero.findFriends();
    
 for (var j = 0; j < friends.length; j++) {
        if (friends[j].type == "soldier") {
            soldiers(friends[j]);
        }}

#2

look like “warlock” cast some spell on my soldiers to fight against me and it crash my code. How to fix it? How to check friend state if he still a friend?


#3

You think it may be a bug?


#4

maybe I need something like

if(friend.hasEffect === false){
     command();
}

also this level is really glithcy, it take all my RAM memory and I can not work with flags.


#5

Ok…you may need @nick or @ChronistGilver


#6

new problems

  1. all RAM used

  1. my troops don’t follow me after doors is fallen


#7

this is code for soldiers and archers

I separate them into 2 functions, nothing superHard


function archersCommand(archers) {
    for (var i = 0; i < archers.length; i++) {
        var enemy = archers[i].findNearestEnemy();
        var enemy2 = hero.findNearestEnemy();
        if (enemy) {
            hero.command(archers[i], "attack", enemy);
        } else {
            hero.command(archers[i], "defend", hero.pos);
        }
    }
}
function soldiersCommand(soldiers) {
    for (var i = 0; i < soldiers.length; i++) {
        var enemy = soldiers[i].findNearestEnemy();
        var enemy2 = hero.findNearestEnemy();
        if (enemy) {
            hero.command(soldiers[i], "attack", enemy);
        } else {
            hero.command(soldiers[i], "defend", hero.pos);
        }
    }
}

and call them into while loop

while (true) {
    startOfStage(stage);
    attackStage(superunits[stage]);
    paladinHealing(hero.findByType("paladin"));
    soldiersCommand(hero.findByType("soldier"));
    archersCommand(hero.findByType("archer"));
    cleaningStage();
    endStage();
}

#8

I place this fucntion on top of the list, now they attack.

while (true) {

    soldiersCommand(hero.findByType("soldier"));
    archersCommand(hero.findByType("archer"));
    startOfStage(stage);
    attackStage(superunits[stage]);
    paladinHealing(hero.findByType("paladin"));
    cleaningStage();
    endStage();
}

#9

This level crashes Chrome browser a few times because 4 GB memory is no enough to run CodeCombat
and thanx for not much help

painfully

Victory.

it was hard not about coding but about lags


#10

FPS = pain in the butt


#11

You need someone to help?


#12

no. coz I have VICTORY already. but freaking FPS !

I have 200 lines of code, and after each editing this was real pain to test the level



#13

#I pass this level with 20 lines of code(python), and my computer has only 3G RAM.


#14

20 lines is awesome, man