My code for this level brings it to the center, but then it stops. It is only 2 meters from the Treasure Chest. Can anyone fix this because it is getting very annoying now?

Could you please insert your code, here? Otherwise i can’t help you, neither can anyone else.

Here is my code:

var r = 10;

var diff = 0.5;

var threshold = 5.7;

var S = 3;

var circle = 5;

var cx = 68,

cy = 68;

// hero.moveXY(132, 70);

// hero.stomp();

function prepareMap() {

var map = ;

for (var y = 0; y < 135; y++) {

var row = ;

for (var x = 0; x < 160; x++) {

row.push(0);

}

map.push(row);

}

var hazards = hero.findHazards();

for (var i = 0; i < hazards.length; i++) {

var hx = Math.round(hazards[i].pos.x);

var hy = Math.round(hazards[i].pos.y);

map[hx][hy] = 1;

}

return map;

}

function buildRect(x1, y1, x2, y2) {

if (x1 === x2) {

return [[x1 - S, y1], [x1 + S, y1], [x2 - S, y2], [x2 + S, y2]];

}

var tang = (y1 - y2) / (x1 - x2);

var ang = Math.atan(tang);

}

var rad = Math.PI * 2 / 360;

hero.moveXY(128 - r / 2 - diff, 68);

// var iceM = prepareMap();

var angle = 0;

while(true) {

if (!circle) {

break;

}

var R = r * circle + r / 2 - diff;

var iR = R - r;

while (true) {

angle = (angle + 2) % 360;

var x = cx + Math.cos(angle * rad) * R;

var y = cy + Math.sin(angle * rad) * R;

var ix = cx + Math.cos(angle * rad) * iR;

var iy = cy + Math.sin(angle * rad) * iR;

// buildRect(x, y, ix, iy);

// hero.debug(hero.isPathClear({x: x, y: y}, {x: ix, y: iy}));

// hero.say(x);

// hero.say(y);

hero.moveXY(x, y);

var nearest = hero.findNearest(hero.findHazards());

if (hero.distanceTo(nearest) >= threshold) {

hero.debug(angle, hero.distanceTo(nearest));

// hero.say(nearest.pos.x + “-” + nearest.pos.y);

// hero.say(ix + “-” + iy);

hero.moveXY(ix, iy);

// hero.say(nearest.pos.x + “-” + nearest.pos.y);

circle–;

break;

}

}

}

Sorry, I am not so used to the formatting.

It is okay as long as it is not python.

Its JavaScript

(20 characters)

Um, I haven’t beat this. (aka haven’t tried)

That’s okay, just as long as I can get help for it.

I mean, I can’t really help, Although, I have an idea…

@Chaboi_3000

Alisha needs your help in this level, sorry about the inconvenience.

I will try my best to help before Chaboi starts. He pretty much beat code combat

Looks like you need to make him go in, and not around.

I’ve been trying for a while, but it is not helping out much with what I tried to do.

Thanks anyway!

@Ironhead

Hmm. It seems like the chest is in a weird place. So try changing the center point.

Your code looks correct. Looks like it’s an equipment specific problem. Could you say your CodeCombat nickname and I will try to research the problem and solve it?

@Bryukh

Okay. It is Amy Cahill.

Hm, I’ve completed the level with your account without problems. Could you send some screenshots of the error?

Sorry for the new account. I fixed the code now with some help from a friend who completed it.