Need help to back to back


#1

don’t know how to do this level back to back. So it would be nice if some one gave the correct code


#2

What language are you programming in ?
Could you provide me with a link of the level (url). I don’t know by heart all the levels. At least tell me the map and the number of the level.


#3

if its the level i think, its w2 in South. in german “Rücken an Rücken”.

u should start with a loop… in there you have to decide it theres an enemy or not. If there is a enemy go and Kill him, if not go to (40|34)


#4

Default code being

loop 
    enemy = this.findNearestEnemy();
    if (enemy) {
        // 
        
    }
    else {
        // 
        
    }
}

A correct code in JavaScript could be the following. If you came here to ask for help for two lines of code, I guess it’s better to give you a full answer. :

loop{
    enemy = this.findNearestEnemy();
    if (enemy) {
        // 
        this.attack(enemy);   
    }
    else { 
        // 
        this.moveXY(40,34);
    }
}

Hope this helps. What didn’t you understand ? In my (french) version, I had a little syntax bug, the last } was replaced with an “end”. I removed it to generate the code above. Maybe that was your problem ?


#5

my programing language is python


#6

thank you so much for your help


#7

OK, default code fixed, it will wend it’s way out to everyone in time. Thanks!