# Python: Treasured In Ice

I need some help with this level. Can someone tell me how to make the visited array and add to it, and also how to look for the treasure, anything is appreciated!
Here is my code so far:

``````exitPosition = {"x": 150, "y": 120}
zeroShift = {"x": 10, "y": 10}
distance = 16
move = Vector(distance, 0)
direction = Vector.add(move, hero.pos)
while True:
while not (hero.isPathClear(hero.pos, direction)):
move = Vector.rotate(move, Math.PI / 2)
direction = Vector.add(move, hero.pos)
# hero.say(direction)
hero.moveXY(direction.x, direction.y)
move = Vector.rotate(move, -Math.PI / 2)
direction = Vector.add(move, hero.pos)

``````

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review this topic, which shows all essentials of this board! Thanks!

Oh. I’m not good at this stuff, @Eric_Tang or @Falcons118 someone needs help on vector! (I think)

I just added a little more but he is moving very slowly

``````# Find the treasure inside the maze.
# When you get the treasure, move to the exit.
# The exit is marked by the red cross. The level ends when you step on the mark.
# Some doors are blocked, some open when you are near them.

exitPosition = {"x": 150, "y": 120}
zeroShift = {"x": 10, "y": 10}
distance = 16
move = Vector(distance, 0)
direction = Vector.add(move, hero.pos)
visited = []
visited2= []
def checklocation(x, y):
for i in range(len(visited)):
k = visited[i]
for j in range(len(visited2)):
f = visited2[j]
if (x, y) != (k, f):
hero.moveXY(x,  y)
while True:
visited.append(hero.pos.x)
visited2.append(hero.pos.y)
while not (hero.isPathClear(hero.pos, direction)):
move = Vector.rotate(move, Math.PI / 2)
direction = Vector.add(move, hero.pos)
# hero.say(direction)
checklocation(direction.x, direction.y)
chest = hero.findNearestItem()
if chest:
cd = hero.distanceTo(chest)
if cd <=16:
hero.moveXY(chest.pos.x, chest.pos.y)
move = Vector.rotate(move, -Math.PI / 2)
direction = Vector.add(move, hero.pos)
``````
1 Like

What hero are you using

Alejandro but I’ve used him the whole time up to that level

You may wana use a different Hero. Alejandro isn’t as fast as some of the other ones. Also welcome to the forum!

1 Like

It says that my code is to slow or infinite

Yea thats more than likely related to the hero or weapons that you are using

no, it means his/her code is wrong.

Not necessarily. For example one level I did I was using a starter hero. However because his abilities were so limited it kept going on and on and on…