I need code for Summits Gate!


#1

I have tried just about everything to get past Summits Gate and I really need some code!


#2

We don’t give away solutions as per the forum policy. Please post the code that you are having problems with and explain what is not going as expected, then we can help you through. :slightly_smiling:


#3

This is my code:

// Fight your way into the Inner Sanctum of the ogre chieftain, and kill her.
loop {
    var enemy = this.findNearest(this.findEnemies());
    var flag = this.findFlag("green");
    var blackflag = this.findFlag("black");
    if(flag){
        this.pickUpFlag(flag);
    }
    if(blackflag){
        this.jumpTo(blackflag.pos);
        this.pickUpFlag(blackflag);
    }
    if (enemy) {
        this.attack(enemy);
    }
    if(this.gold >= this.costOf("soldier")){
        this.summon("soldier");
        var friends = this.findFriends();
        for(i=0; i<friends.length; i++){
            var friend = friends[i];
            this.command(friend, "defend", this);
        }
    }
    
}

I always die when I reach the beam towers


#4

Please format your next posts’ code according to the FAQ. I’ve done this for you this time.

Now for the main topic. Summit’s Gate is a very difficulty level, even more so if you have only the free heroes—but it is still manageable even so. You will need a bit more of strategy in order to beat it. Here are some general points:

  • You want to command your paladins to heal your hero whenever your hero’s health is below a certain threshold, and your paladins’ heal spell has cooled down (check with the canCast('heal') method on your paladin units).

  • Once you reach a gate door, you may take some time to wait and heal yourself. That is, wait until your hero has regained their health before you break the door. if I recall correctly, I did this by excluding doors from the array returned by this.findEnemies() and used a flag to signal when the door should be destroyed.

  • The towers are by far the most challenging part of this level, in my opinion. My personal strategy for beating them was:

    1. Before the door, wait enough time until your hero has got back to full health (don’t break the door early, wait for the paladins to cast heal on you a couple times until your health is full). You have to write code to command the paladins to cast heal on you whenever they can and you have less than max health, as I’ve already mentioned.
    2. Break the door and immediately back away with your troops, don’t go past the gate just yet. The ogres will come after your hero and you will be able to kill all of them without the beam towers roasting your hero while you do that.
    3. Then, only then, command your hero attack a beam tower. Note that the beam towers’ range is limited, so you can attack one while staying out of the other tower’s range—if you are attacking the top one, stay above the tower so the bottom one cannot attack you. Likewise, the same applies to the bottom one: stay as far as you can from the opposite tower while you attack one of them.
    4. At this point, one tower will be inactive and the other will be focusing its beam at your hero. You should be able to command your paladin(s) to stay near the hero, away from the opposite tower and outside of the tower your hero is attacking’s beam line. This will allow the paladin(s) to heal your hero without being hurt by the towers while the hero takes down the towers.
    5. You can use your remaining units to attack the towers. Ideally, they should be able to attack the towers from a position that is not in the opposite tower’s range and outside of the tower that your hero is attacking’s beam line. Don’t be afraid if all your other units die in this section, you will be joined by more than enough troops in the next section if you manage to destroy the towers and stay alive.

You can find more tips along the other Summit’s Gate thread. Good luck! :smile:


#5

Just run past the beam towers, you’ll find more troops on the other side. The come back with extra troops and destroy the towers.

Put the “tower” into an to_avoid array.
Also try to write code that considers each phase of the battle:

  1. phase 1: destroy the outside army and the catapults.
    Put the “door” on to_avoid, try to not get blown by the catapults too much

  2. phase 2: smash through the first 2 gates
    take the “door” from avoid, put the towers on avoid

The level is very long with at least 5 separate phases which require different strategies.
Prepare for one week of coding and trying :slight_smile: :stuck_out_tongue:


#6

As Adrian has stated.
I’ve just started working on this yesterday.

Right now I’ve written code for the first phase. (You can use different colour flags to signal which phase you’re on if you’d like to keep manual control) I’ve been using either my location, or the alive status of the doors etc. Played with a few different options to see which I like best.

Once you know you have something that works for phase 1, make a code that breaks out of it. (With the flags I guess this would be easy. > if (this.findFlag(“green”)) break; should work.

That will allow you to complete phase 1 and easily separate it from phase 2. Using the flag to focus on phase 2 code loop (Or case, or function, or however you choose to separate it)… Now that I’ve considered this aloud; I believe I will use this in my testing, thanks!

This way you can continue to tweak and optimize the results and methods in each phase separately, and then choose what can maintain a primary loop and what should be translated into functions/routines. And of course you can after you have working loops, find automated ways to outline when each phase is active.

Time to go write some code, thanks again!


#7

so what gear did you have?


#8

I used a Goliath with the best chest armor and best sword. But the hero is not essential on this level - I didn’t even bothered to write code for the Goliath’s abilities.

I had a very fancy code but was not working - laggy, hard to parametrize. Flags also are not working on this level because of the lag.

So I rewrote everything from scratch using some simple dumb code that also happens to extremely efficient.

Catapult phase (spoilers)

Split the melee troops into 2 groups and have them dash for the catapults.
Pull back the archers and the hero (my hero is slower), make them wait for a few seconds.
Then have them attack nearest enemies.
Result: the melee troops overrun the catapult shots which instead decimate the enemies following them.
The archers came from behind and wipe any unfortunate survivors

Tower phase (spoilers)

Smash the door and pull back to lure the enemy outside the tower zone.
But the towers rays still skewer all your troops. Combined with the door turn that forces your troops to line up, it will result in a total wipe on your side.

                   Your troops
Death ray <<----X-Y-Y-X---X-Y--Y------[Tower]
Tower continuation (spoilers)

Solution: Send your hero only to attack the towers. Position him enough further up so it is attacked by only one tower.
Have your 2 paladins heal him. If your’re lucky they will stay by the door outside the tower range. If you’re not lucky they might die (unless you write smarter code to make them dance in an out, but I couldn’t be bothered).

========================================
After 2 phases I had only 4 casualties and a huge army. It was too late at night and I couldn’t be bothered so I just thrown the ugliest attacking code, resulting in total carnage on both sides. But if you want the next 2 or 3 fights can also benefit from a bit of strategy, so if your hero is not strong enough, you’ll have to code more :slightly_smiling:.

===================================================

Do not use flags, makes the result unpredictable. Use this constructions instead:

Simple ways to automate phase transitions and behavior during a phase
time=this.now();
while(this.now() < (time + DURATION)){  
//by now everyone should be dead/ or in the right place, moving on

removeType("door",enemies_list);
//do not attack those pesky doors

while(enemies_list.length > number)
while(enemy.health > 0)
// the bad guys are dead now, let's move on

groupAttack(allies_in_group, target, enemies_list, position)
// everyone in group attack the target, or the nearest enemy if the target is dead, or move to position

#9

I cant even run past the beam towers even when i use speed ring with softened leather boots i have like around 3400 health
I die because i take too much damage from the catapult and all my troops die from it too
I use Tharin and i have a runesword which was the only sword i could get


#10

Click on the triangled lines on my reply above for hints about the strategy
I did not put it in clear because I do not want to spoil the fun of people trying to come with something by themselves.

Shortly, if you write the code correctly, you will not lose more than 5 soldiers to catapults + towers combined


#11

i cant even attack
i only attack once and he stops attacking
do i have something missing

enemy = self.findNearest(self.findEnemies())
loop:
    if enemy:
        self.attack(enemy)

#12

I can solve that problem for you, after you have killed an enemy you need to redefine ENEMY, so you need to have the:
enemy = self.findNearest(self.findEnemies()), bit of code in your loop.


#13

Thanks!
and also does the towers count as ogres


#14

Yes :smiling_imp:
…


#15

I am never going to solve this its too hard i dont have good gear and i also cant get gems from repayable levels because its too hard. also those levels give me like 200 gems when it says 1700 gems.
i think i may me done for in codecombat this level is impossible with warrior and the gear i have


#16

what does the powerup for the darksteelblade do ?


#17
  1. The ladder levels gems is still a bit bugged. Until recently if you were at 5th level ladder and the screen said you got 1700 gems, it meant you got 1700 for all your victories:
    1st_victory.gems +2nd_victory.gems + 3rd_victory.gems + 4th + 5th = 1700

  2. If you are really stuck create a new thread and say “I bought stupid stuff and now I’m stuck. I beg for pity. Please refund”. :slightly_smiling:

If the admins are able to find some spare time, they could TAKE AWAY all your gems bought items and give you back their cost in gems. Please note that it may take you some time


#18

i know that its not a glitch


#19

finally i finished it with this code
more simple than i expected with flags

self.summon("soldier")
self.summon("soldier")
self.summon("soldier")
self.summon("soldier")

loop:
    flag = self.findFlag("green")
    warlock = self.findNearest(self.findByType("warlock"))
    chief = self.findNearest(self.findByType("chieftain"))
    witch = self.findNearest(self.findByType("witch"))
    if flag:
        self.pickUpFlag(flag)
    if witch:
        self.attack(witch)
    if chief:
        self.attack(chief)
    if warlock:
        self.attack(warlock)
    else:
        enemy = self.findNearest(self.findEnemies())
        if enemy:
            self.attack(enemy)
        

#20

is it normal all friendly npcs run into close combat without attacking anything?