Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED] Help with Fragile Maze in the Glacier

Here is my code. This level is very buggy and frequently returns true when it’s actually the opposite. Thanks for the help you can offer. @AnSeDra @dedreous @Deadpool198 @brooksy125

// Escape from the maze!
// Some doors are blocked, some open when you are near them.

var distanceBetweenRooms = 16;
var startRoom = {x: 18, y: 19};

var clearUp = function () {
    if (hero.isPathClear(hero.pos, {'x': hero.pos.x, 'y': hero.pos.y + 16})) {
        return true;
    }
};

var clearRight = function () {
    if (hero.isPathClear(hero.pos, {'x': hero.pos.x + 16, 'y': hero.pos.y})) {
        return true;
    }
};

var clearLeft = function () {
    if (hero.isPathClear(hero.pos, {'x': hero.pos.x - 16, 'y': hero.pos.y})) {
        return true;
    }
};

var clearDown = function () {
    if (hero.isPathClear(hero.pos, {'x': hero.pos.x, 'y': hero.pos.y - 16})) {
        return true;
    }
};

var moveUp = function () {
    hero.moveXY(hero.pos.x, hero.pos.y + 16);
};

var moveLeft = function () {
    hero.moveXY(hero.pos.x - 16, hero.pos.y);
};

var moveRight = function () {
    hero.moveXY(hero.pos.x + 16, hero.pos.y);
};

var moveDown = function () {
    hero.moveXY(hero.pos.x, hero.pos.y - 16);
};

while(true) {
    if (clearLeft() && clearRight() && clearUp() && clearDown()) {
        moveRight();
    } else if (clearUp()) {
        moveUp();
    } else if (clearRight()) {
        moveRight();
    } else if (clearDown()) {
        moveDown();
    } else if (clearLeft()) {
        moveLeft();
    } 
}

Sorry, but I can not help you unfourtunaly because I will have to go to sleep soon. But @dedreous and @Deadpool198 might be able to help you.

Andrei

Don’t worry. In the end, I found something that worked. But this is an extremely tough level, it will take a lot of research to solve it…

1 Like

Ok, but I wanted to suggest you what to do. Sorry for letting you wait so much for a answer!

Andrei