soneo
January 22, 2016, 6:12pm
1
Hi,
to begin i started codecombat a week age and i thanks all the participants. very interesting website.
I am coming here because i’m bloqued on the “grim determination” level , i tried to kill the “warlock” first , i tried to kill the highest life first, i tried to kill the slowest life first and no way, i didn t understand how we can win.
Can you show the map with the highlighted level? And please mention if you are using a free account.
soneo
January 22, 2016, 6:25pm
3
Hi , yes i’m playing for free. here is my code .
i tried différents way but i cant succed this level
thanks for your help
`
this.lowestHealthPaladin = function() {
var lowestHealth = 99999;
var lowestFriend = null;
var friends = this.findFriends();
for(var f=0; f < friends.length; f++) {
var friend = friends[f];
if(friend.type != "paladin") { continue; }
if(friend.health < lowestHealth && friend.health < friend.maxHealth) {
lowestHealth = friend.health;
lowestFriend = friend;
}
}
return lowestFriend;
};
this.lowestHealthenemy = function() {
var lowestHealthenemy = 99999;
var lowestenemy = null;
enemies=this.findEnemies();
for(var f=0; f < enemies.length; f++) {
var enemy = enemies[f];
if(enemy.health < lowestHealthenemy ) {
lowestHealthenemy = enemy.health;
lowestenemy = enemy;}
}
return lowestenemy;
};
this.commandPaladin = function(paladin,lowestFriend) {
this.esquiveprojectile(paladin);
lowestFriend=this.lowestHealthPaladin();
lowestenemy=this.lowestHealthenemy();
if(paladin.pos.x<80){this.command(paladin, "move", {x:paladin.pos.x+10,y:paladin.pos.y});}
if(lowestFriend){
if(paladin.canCast("heal")){this.command(paladin, "cast", "heal", lowestFriend);}}
else{if(lowestenemy){this.command(paladin, "attack", lowestenemy);}}
};
this.commandFriends = function() {
// Command your friends.
var friends = this.findFriends();
for(var i=0; i < friends.length; i++) {
var friend = friends[i];
if(friend.type == "peasant") {
this.commandPeasant(friend);
} else if(friend.type == "griffin-rider") {
this.commandGriffin(friend);
} else if(friend.type == "paladin") {
this.commandPaladin(friend);
}
}
};
this.commandPeasant = function(peasant) {
peasants = this.findByType("peasant");
for (var i =0 ; i < peasants.length ; i ++) {
peasant = peasants[i];
coins = this.findItems();
nearestCoin = peasant.findNearest(coins);
if (i === 0 && nearestCoin.pos.y < 41){
this.command(peasant, "move", nearestCoin.pos);
}
else if(i === 0 && nearestCoin.pos.y > 41){
this.command(peasant, "move", {x:27,y:24});
}
else if (i === 1 && nearestCoin.pos.y >= 41){
this.command(peasant, "move", nearestCoin.pos);
}
else if(i === 1 && nearestCoin.pos.y < 41){
this.command(peasant, "move", {x:27,y:65});
}
}
};
this.summontroops=function(){
if(this.gold>=this.costOf("griffin-rider")){
this.summon("griffin-rider");
}
};
this.commandGriffin=function(friend){
enemy=this.lowestHealthenemy();
if(enemy){this.command(friend, "attack",enemy);}
else{this.command(friend, "defend",{x:97,y:50});
}};
this.esquiveprojectile=function(paladin){
var enemyMissiles = this.findEnemyMissiles();
if(enemyMissiles[0]){
if(paladin.distanceTo(paladin.findNearest(enemyMissiles))<20){
if(paladin.pos.y<41){this.command(paladin, "move", {x:paladin.pos.x, y:paladin.pos.y+10});}
else{this.command(paladin, "move", {x:paladin.pos.x, y:paladin.pos.y-10});}
}}};
loop {
this.commandFriends();
// Summon griffin riders!
this.summontroops();
}
`
Oh dear, I have no idea on how to do this, but I’ll refer to to someone who knows more.
i dont know i dont even know the language and also what level this is
cool looking level though
I am pretty sure this is JavaSript.
Your code keeps crashing my intepreter
Best advice is to save it in a file, the click the reload button to start from new code.
The issue seems to be that you do not get to attack offen enough.
Solution:
drop the x>80 code, your paladins will naturally go forward if they attack all the time
drop the attack weakest code, they will just dance around each other trying all to attack the same enemy
attack the nearest
Implement a tight logic in paladin control, making sure they always do one action per function call:
function command paladin
if (can heal and healling target)
command heal
return; //exits the function
if( health very very low)
command shield
return
if( enemy)
command attack
return
// else
command move
}
soneo
January 24, 2016, 12:55pm
9
Thanks a lot… thanks to you i ve passed this level…