Finally solved Thunderhooves!


After around thirty minutes I finally solved the level Thunderhooves! It actually proved to be difficult compared to most of the previous levels, I myself have little programming knowledge prior to code combat and was having trouble at first with the level. I remembered previously it stated that enemies can have a position assigned as well as myself. I would have not been able to solve the puzzle if I had not remembered that.

I would like to make a suggestion, a full out solution for an example would be a bad idea as that would make things too easy. On the self.pos item it would have made my night a little less hectic had there been a tip or reminder that enemies also have positions assigned to them. With that little tip it would have been much more smooth to solve the problem. It does mention in the help section that the yak has a position, just was not to clear the formula is similar to finding our own.

I enjoyed the challenge even though it was quite frustrating! I simply feel as if a younger person was in my predicament and new to coding, they would have had a very difficult time.


I’m agree with you. Properties and method for this are quite well explained, but that’s not the case for the ennemy or object.
When the debugger was allowed, it was possible to view information about a variable, but that’s not the case anymore.


Feel free to edit the hints of the level. When you feel that everything important is mentioned, submit a patch and it will eventually be incorporated.

In the level-editor you can adjust the help-texts ect. Simply submit a patch after you
finished, and if it fits the intentions, it will be accepted and
included in the level.

The concrete level in the editor is actually this one, the above is the general link.
You can access the example-code by doubleclicking the Hero-Placeholder, scrolling down to programming.Programmable, expanding programmable methods and then plan.

You can adjust languages, source and comments.


My JS code looks like this:

loop {
    var enemy = this.findNearestEnemy();
    if (enemy){
        if (this.distanceTo(enemy) < 20){
            var x = enemy.pos.x;
            var y = enemy.pos.y - 10;
            this.buildXY("fence", x, y);
        if (this.distanceTo(enemy) > 10){
            x = enemy.pos.x;
            y = enemy.pos.y + 10;
            this.buildXY("fence", x, y);
        else {
            // Move right 10m towards the oasis.
            x = this.pos.x + 10;
            y = this.pos.y;
            this.moveXY(x, y);

Why won’t it work?


Fixed your indentations.

You only ever have the possibility to move if there is an enemy visible. You may want to change it to

    var enemy = this.findNearestEnemy();
        //Deal with it
        //Move towards oasis

To further improve this: Check also the distance to the enemy if your visual range is to big.

if (enemy && this.distanceTo(enemy) < 9001)

This works even if no enemy is present, because the condition exits early when it can’t be fullfilled anymore.
If there is no enemy, the AND can’t become true anymore, therefore you won’t get an error because you try to this.distanceTo(null).