# Help with Fragile Maze

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()
``````

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.

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()

``````

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

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.

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

1 Like

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

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.

2 Likes

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)

3 Likes

Sorry I was on vacation.

2 Likes