First time I tried to access to this level, I got an infinite loop.
The code example has nothing to prevent it.
Hmm, which language? The current sample code shouldnāt include any infinite loops in any languages that I can see, but I might be missing something. (Also, is there a JS error in the console saying how itās actually some other error, or is it actually an infinite loop?)
Itās in JS.
I was using the link in the mail. I must use the possibility to comment the code to get access to the level. I got the error (infinite loop with a popup, I did not check the console) during the loading.
Hereās the default code :
loop {
var gem = this.findNearest(this.findItems());
if (gem) {
var clear = this.isPathClear(this.pos, gem.pos);
// The isPathClear method tells you if thereās an obstacle in the way.
// If itās clear, move() to gem.pos.
// Else, move back to the center point.
}
}
As it does no action, I supposed it loops very fast and endlessly.
I just try to reset the code, and the error did not appear anymore. Anya just do nothing.
Hello.
I do not have time. Although there is no mention of the limitation.
I do popodalis into any trap and find all diamonds. But I can not win because time is over
Here is my code:
angle = Math.PI / 2 - Math.PI / 16
center = {"x":40,"y":35}
def movePos(angle):
targetX = self.pos.x + 3 * Math.cos(angle)
targetY = self.pos.y + 3 * Math.sin(angle)
return {"x":targetX,"y":targetY}
loop:
gem = self.findNearest(self.findItems())
if gem:
clear = self.isPathClear(self.pos, gem.pos)
if clear:
self.move(gem.pos)
elif self.isPathClear(self.pos, center):
self.move(center)
else:
new_pos = movePos(angle)
while self.isPathClear(self.pos, new_pos) != True:
angle -= Math.PI / 16
new_pos = movePos(angle)
self.move(new_pos)
Ah, very clever! Iāve increased the lifespan of the level by 5s, so you should be able to finish it now.
Sweet code reuse.Ā
@insaf121
Nice! really smart! never thought about something like that! (This kinda lame, but the only way I could think of finishing it witout using the original code was to just get the X and Y positions and use the āmoveXYā function )
self.isPathClear does not seem to register the traps in Python, even though it says it should. It is making this level very difficult without manually choosing my locations.
Hmm, is working for meā¦
Did you rewrite the code? or just add the two lines it wants you to add?
(this is one of the ādonāt think to hard or youāll break itā levels.)
It works now, but the pathing is quite weak. It will say the path is clear but I will often clip the corner of the trap. But I have finished the level at least.
Make sure you use Compound Boots and the move function (not moveXY) on this level. As the comments in the code suggest, should only be a few lines of code.
Awesome!
I did some modifications on your code.
Itās in the javascript syntax now.
For those who might need it.
(Solution removed)
Please donāt post solutions. The purpose of this board is to help people learn so that they can figure out levels on their own. Simply providing solutions does not help and is counterproductive. Thanks.