Help with Fragile Maze


#1

How do make sure that I am not moving into the same room I was already in, and it says Line 20: Error: Cant find matching loop frame for break.

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

distanceBetweenRooms = 16
startRoom = {"x": 18, "y": 19}
def up():
    if hero.isPathClear(hero.pos, {"x": hero.pos.x, "y": hero.pos.y + distanceBetweenRooms}):
        hero.moveXY(hero.pos.x, hero.pos.y + distanceBetweenRooms)
    else:
        break
def down():
    if hero.isPathClear(hero.pos, {"x": hero.pos.x, "y": hero.pos.y - distanceBetweenRooms}):
        hero.moveXY(hero.pos.x, hero.pos.y - distanceBetweenRooms)
    else:
        break
def right():
    if hero.isPathClear(hero.pos, {"x": hero.pos.x + distanceBetweenRooms, "y": hero.pos.y}):
        hero.moveXY(hero.pos.x + distanceBetweenRooms, hero.pos.y)
    else:
        break
def left():
    if hero.isPathClear(hero.pos, {"x": hero.pos.x - distanceBetweenRooms, "y": hero.pos.y}):
        hero.moveXY(hero.pos.x - distanceBetweenRooms, hero.pos.y)
    else:
        break
while True:
    up()
    right()
    left()
    down()

#2

Well, make an array storing your position every time you go into a room, and if the target pos is equal to one of the elements in the array, then you continue.


#3

Now it says Can’t find matching loop frame for continue.

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

distanceBetweenRooms = 16
startRoom = {"x": 18, "y": 19}
def up():
    if hero.isPathClear(hero.pos, {"x": hero.pos.x, "y": hero.pos.y + distanceBetweenRooms}):
        hero.moveXY(hero.pos.x, hero.pos.y + distanceBetweenRooms)
        startRoom = hero.pos
        continue
    elif startRoom == hero.pos:
        hero.moveXY(hero.pos.x, hero.pos.y - distanceBetweenRooms)
        startRoom = hero.pos
        continue
    else:
        continue
def down():
    if hero.isPathClear(hero.pos, {"x": hero.pos.x, "y": hero.pos.y - distanceBetweenRooms}):
        hero.moveXY(hero.pos.x, hero.pos.y - distanceBetweenRooms)
        continue
    elif startRoom == hero.pos:
        hero.moveXY(hero.pos.x, hero.pos.y + distanceBetweenRooms)
        startRoom = hero.pos
        continue
    else:
        continue
def right():
    if hero.isPathClear(hero.pos, {"x": hero.pos.x + distanceBetweenRooms, "y": hero.pos.y}):
        hero.moveXY(hero.pos.x + distanceBetweenRooms, hero.pos.y)
        continue
    elif startRoom == hero.pos:
        hero.moveXY(hero.pos.x - distanceBetweenRooms, hero.pos.y)
        startRoom = hero.pos
        continue
    else:
        continue
def left():
    if hero.isPathClear(hero.pos, {"x": hero.pos.x - distanceBetweenRooms, "y": hero.pos.y}):
        hero.moveXY(hero.pos.x - distanceBetweenRooms, hero.pos.y)
        continue
    elif startRoom == hero.pos:
        hero.moveXY(hero.pos.x + distanceBetweenRooms, hero.pos.y)
        startRoom = hero.pos
        continue
    else:
        continue

while True:
    up()
    right()
    left()
    down()


#4

Don’t use continue in else, since it can’t continue to any other loop frames.


#5

Try for looping through the array filled with the rooms you’ve been to, and check to see if the new room as been visited yet. if so, do nothing. Else, move to the room.


#6

Could you give additional information about what is happening? The world you are on, the level(which I see), and maybe a screenshot if possible


#7

Why do you need the world? Just do codecombat.com/play/level/fragile-maze.

Whatever level it is just put its name after the slash thing


#8

If they haven’t given me the link to it, then I ask them for the world so I can manually find the level. Also, this conversation is off-topic. Lets try to stick to the topic.:face_with_raised_eyebrow::hushed:


#9

How am I being off-topic? (first of all you started it)

No, you don’t understand what I mean.

At the top it says “Help with Fragile Maze”, so the level name is obviously called Fragile Maze.

So you put it after the slash after level: codecombat.com/play/level/

And it becomes codecombat.com/play/level/fragile-maze.

Never manually find a level. EVER. (it’s torturous)


#10

Sorry I was on vacation.