I’m really getting annoyed with this level. The code is so easy but I’m being held back b/c I can’t place the flags fast enough and or my humans keep dying. The code is really simple and I have no real interest in the game itself. It’s just a fun way to utilise the code and learn.
It plays too much like a game. I shouldn’t be held back because I can’t complete it for non-code reasons. I don’t want to waste loads of time until I manage to get all the flags fast enough. Why isn’t there a button to skip all the kiddy game crap and just get on with the code. I enjoy the layout and concept, and having games does make it fun; but this level is ridiculous.
your troups are telling you what kind of enemy ist coming. Then you have sth like 5 seconds, that should be enough to place a flag.
If you got lags in Your game, try to use chrome. If you play on laptop, try to use a mouse, that will make it pretty more easy to place flags…
While you bash pretty hard on the level, you give very little information what exactly is wrong.
As far as I understood, this game targets mainly child’s till the age of 14 (roughly), with nice Graphics and simple commands. As early-20 IT-Student myself I’m highly overskilled for most levels. But even I find some gems which are pretty hard to solve, when restraining myself to lower gear (because I don’t have the gems for better gear) or targeting high-scores.
So as you seem to not be a part of the target audience, this game maybe simply isn’t something for you. And if you got to Sarven Sentry, you actually encountered a lot of kiddy game crap, so I can’t really see your point. The whole dungeon-area is kiddy game crap compared to this.
Now to flags: While it is pretty hard to play a level with flags when there is really much action going on, Sarven Sentry is not one of them. I tested the level on multiple browsers, and while I can not say that Chrome is the ultimate solution, it works there. Also in Firefox, which is fast for me as well.
Placing flags is extremely easy. Once you submitted, you can use Hotkeys to select the flag you want, and the scout’s reports give you enough time to switch the flag (even without hotkeys) and place it. If you do not wear reinforced boots (which slow you) you can even issue the command once the enemy is visible, though I would call this the hardcoremode of the level.
Hi sorry if I seemed a bit rude, I do like codecombat! I was just really frustrated this morning. I am doing the mission with a laptop and my trackpad wasn’t fast enough. The kiddy game crap comment seems a bit horrible now. I apologise.
No problem, everybody has a bad morning from time to time.
I came up with kind of a solution, but it fails at one point. The flag has no flag.distanceTo Method and the VectorAPI is not enabled. Maybe @nick knows a solution. I marked in the code where I’d need it.
Code for *not so precise* flags
//JavaScript, you may have to translate
var positions = [{x:53, y:53},
{x:30, y:61},
{x:16, y:50},
{x:19, y:29},
{x:33, y:11},
{x:56, y:14},
{x:65, y:38}];
function snap(flag){
var dist = 9001;
var position = null;
for(var p in positions){
var temp = Vector.subtract(positions[p], flag.pos).magnitude; //HERE!!!!
if(temp < dist){
dist = temp;
position = positions[p];
}
}
return position;
}
loop{
flagGreen = this.findFlag("green");
flagBlack = this.findFlag("black");
flagViolet = this.findFlag("violet");
var pos;
// If there's a green flag, build a fence.
if (flagGreen){
pos = snap(flagGreen);
this.buildXY("fence", pos.x, pos.y);
this.pickUpFlag(flagGreen);
// If there's a black flag, build a fire trap.
}
else if (flagBlack){
pos = snap(flagBlack);
this.buildXY("fire-trap", pos.x, pos.y);
this.pickUpFlag(flagBlack);
}
// If there's a violet flag, just move to its location.
// Remember to pick up flags after you're done with them!
else if (flagViolet){
this.pickUpFlag(flagViolet);
}
else{
this.moveXY(43, 31);
}
}
To make this clear: The code at the moment is not working, because I’m lacking a possibility to measure the distance between two arbitrary points.
(every time I put these comments below the code they pop out of the “details” container.)
var temp = distBetweenPos((positions[p], flag.pos))
If Math.sqrt is to slow, then remove it and remember you can only compare distBetween with another distBetween. (maybe add Sqrd to the name: distSqrdBetween…)
Thanks at Vlevo for pointing this out. I somehow assumed that if the Vector-API is disabled, the Math-API is disabled as well and didn’t even bothered trying.
**Working** Code for *not so precise* flags
//JavaScript, you may have to translate
var positions = [{x:53, y:53},
{x:30, y:61},
{x:16, y:50},
{x:19, y:29},
{x:33, y:11},
{x:56, y:14},
{x:65, y:38}];
function snap(flag){
var dist = 9001;
var position = null;
for(var p in positions){
var temp = Math.sqrt(Math.pow(positions[p].x-flag.pos.x,2) + Math.pow(positions[p].y-flag.pos.y,2)); //Because the flag doesn't have a distanceTo-Method
if(temp < dist){
dist = temp;
position = positions[p];
}
}
return position;
}
loop{
flagGreen = this.findFlag("green");
flagBlack = this.findFlag("black");
flagViolet = this.findFlag("violet");
var pos;
// If there's a green flag, build a fence.
if (flagGreen){
pos = snap(flagGreen);
this.buildXY("fence", pos.x, pos.y);
this.pickUpFlag(flagGreen);
// If there's a black flag, build a fire trap.
}
else if (flagBlack){
pos = snap(flagBlack);
this.buildXY("fire-trap", pos.x, pos.y);
this.pickUpFlag(flagBlack);
}
// If there's a violet flag, just move to its location.
// Remember to pick up flags after you're done with them!
else if (flagViolet){
this.pickUpFlag(flagViolet);
}
else{
this.moveXY(43, 31);
}
}
PS.: I use Math.pow for the squares. This is not the recommended way. Math.pow is really, really slow, but has the advantage that it can take (nearly) everything to the power of (nearly) everything. And it is the lazy way. Yup, mostly took it because it’s the lazy way.