# Treasured in Ice

#1

Hi. I need help with this level, I start it but now don’t know how to do, this is my code:
(Hola. Necesito ayuda en este nivel, lo empecé pero ahora no sé que hacer, este es mi código):ç

``````inSearch = True
width = 19
height = 15
def coorConvert(i, dist):
return i * 8 + 10
wall = "X"
unknown = "?"
empty = "."
maze = []
for i  in range(height):
maze.append([wall])
for j in range(width - 1):
maze[0].append(wall)
for i in range(height - 1):
if i % 2:
for j in range(width - 1):
maze[i].append(unknown)
else:
for j in range(width - 1):
if j % 2:
maze[i].append(wall)
else:
maze[i].append(unknown)
for j in range(width - 1):
maze[height-1].append(wall)
for i in range(height):
maze.append([wall])
hero.row = 13
hero.col = 17
exitRow = 13
exitCol = 17
distance = 16
move = Vector(distance, 0)
distanceBetweenRooms = 16
startRoom = {"x": 150, "y": 120}
distance = 16
move = Vector(distance, 0)
while True:
while not (hero.isPathClear(hero.pos, direction)):
move = Vector.rotate(move, Math.PI / 2)
#hero.say(direction)
item = hero.findNearest(hero.findItems())
items = hero.findItems()
for item in items:
hero.move(item.pos)
hero.moveXY(direction.x, direction.y)
move = Vector.rotate(move, -Math.PI / 2)
hero.moveXY(150, 120)
``````

Thank you

1 Like
#2

Why did you get rid of all the comments? (your old post: Help! : Treasured in Ice)

``````inSearch = True   # variable not used

# This whole section is not used in your algorithm yet.
# When you do have a use for it, you can uncomment it back
# by selecting all lines with comments
# and then pressing control + '?'
#
# width = 19
# height = 15
# def coorConvert(i, dist):
#     return i * 8 + 10
# wall = "X"
# unknown = "?"
# empty = "."
# maze = []
# for i  in range(height):
#     maze.append([wall])
# for j in range(width - 1):
#     maze[0].append(wall)
# for i in range(height - 1):
#     if i % 2:
#         for j in range(width - 1):
#             maze[i].append(unknown)
#     else:
#         for j in range(width - 1):
#             if j % 2:
#                 maze[i].append(wall)
#             else:
#                 maze[i].append(unknown)
# for j in range(width - 1):
#     maze[height-1].append(wall)
# for i in range(height):
#     maze.append([wall])
# hero.row = 13
# hero.col = 17
# exitRow = 13
# exitCol = 17

distance = 16
move = Vector(distance, 0)

distanceBetweenRooms = 16                # variable not used
startRoom = {"x": 150, "y": 120}         # variable not used

distance = 16                            # redundant code
move = Vector(distance, 0)               # redundant code
direction = Vector.add(move, hero.pos)   # redundant code

while True:     # can't exit the loop

# replace this comment with something that explains what this while loop does
while not (hero.isPathClear(hero.pos, direction)):
move = Vector.rotate(move, Math.PI / 2)
#hero.say(direction)

item = hero.findNearest(hero.findItems()) # variable not used before reassignment
items = hero.findItems()  # as far as I know, there is only 1 item
for item in items:
hero.move(item.pos)

# why is this section split apart from the while loop above?
# they both deal with hero movement through the maze
hero.moveXY(direction.x, direction.y)
move = Vector.rotate(move, -Math.PI / 2)