# Python: Treasured In Ice

**URL:** <https://discourse.codecombat.com/t/python-treasured-in-ice/27050>\
**Category:** Level Help\
**Created:** [January 27, 2021, 2:56pm UTC](https://discourse.codecombat.com/t/python-treasured-in-ice/27050 "2021-01-27T14:56:02Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ineedhelpwithstuff](https://avatars.discourse-cdn.com/v4/letter/i/3be4f8/32.png) [@ineedhelpwithstuff](https://discourse.codecombat.com/u/ineedhelpwithstuff)\
**Post date:** [January 27, 2021, 2:56pm UTC](https://discourse.codecombat.com/t/python-treasured-in-ice/27050/1 "2021-01-27T14:56:02Z")

</div>

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:

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

```

---

<div class="post-metadata">

**Author:** ![milton.jinich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/milton.jinich/32/21419_2.png) [@milton.jinich](https://discourse.codecombat.com/u/milton.jinich)\
**Post date:** [January 27, 2021, 2:56pm UTC](https://discourse.codecombat.com/t/python-treasured-in-ice/27050/2 "2021-01-27T14:56:22Z")

</div>

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](https://discourse.codecombat.com/t/welcome-to-codecombat-discourse-forums/15601), which shows all essentials of this board! Thanks!

---

<div class="post-metadata">

**Author:** ![Dragonlouis](https://avatars.discourse-cdn.com/v4/letter/d/7cd45c/32.png) [@Dragonlouis](https://discourse.codecombat.com/u/Dragonlouis)\
**Post date:** [January 27, 2021, 3:08pm UTC](https://discourse.codecombat.com/t/python-treasured-in-ice/27050/3 "2021-01-27T15:08:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ineedhelpwithstuff](https://avatars.discourse-cdn.com/v4/letter/i/3be4f8/32.png) [@ineedhelpwithstuff](https://discourse.codecombat.com/u/ineedhelpwithstuff)\
**Post date:** [January 27, 2021, 3:43pm UTC](https://discourse.codecombat.com/t/python-treasured-in-ice/27050/4 "2021-01-27T15:43:03Z")

</div>

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

```python
# 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)

```

---

<div class="post-metadata">

**Author:** ![milton.jinich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/milton.jinich/32/21419_2.png) [@milton.jinich](https://discourse.codecombat.com/u/milton.jinich)\
**Post date:** [January 27, 2021, 3:45pm UTC](https://discourse.codecombat.com/t/python-treasured-in-ice/27050/5 "2021-01-27T15:45:01Z")

</div>

What hero are you using

---

<div class="post-metadata">

**Author:** ![ineedhelpwithstuff](https://avatars.discourse-cdn.com/v4/letter/i/3be4f8/32.png) [@ineedhelpwithstuff](https://discourse.codecombat.com/u/ineedhelpwithstuff)\
**Post date:** [January 27, 2021, 3:49pm UTC](https://discourse.codecombat.com/t/python-treasured-in-ice/27050/6 "2021-01-27T15:49:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Luke10](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/luke10/32/19892_2.png) [@Luke10](https://discourse.codecombat.com/u/Luke10)\
**Post date:** [January 27, 2021, 3:55pm UTC](https://discourse.codecombat.com/t/python-treasured-in-ice/27050/7 "2021-01-27T15:55:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ineedhelpwithstuff](https://avatars.discourse-cdn.com/v4/letter/i/3be4f8/32.png) [@ineedhelpwithstuff](https://discourse.codecombat.com/u/ineedhelpwithstuff)\
**Post date:** [January 27, 2021, 4:04pm UTC](https://discourse.codecombat.com/t/python-treasured-in-ice/27050/8 "2021-01-27T16:04:09Z")

</div>

It says that my code is to slow or infinite

---

<div class="post-metadata">

**Author:** ![Luke10](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/luke10/32/19892_2.png) [@Luke10](https://discourse.codecombat.com/u/Luke10)\
**Post date:** [January 27, 2021, 6:07pm UTC](https://discourse.codecombat.com/t/python-treasured-in-ice/27050/9 "2021-01-27T18:07:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Dragonlouis](https://avatars.discourse-cdn.com/v4/letter/d/7cd45c/32.png) [@Dragonlouis](https://discourse.codecombat.com/u/Dragonlouis)\
**Post date:** [January 27, 2021, 6:37pm UTC](https://discourse.codecombat.com/t/python-treasured-in-ice/27050/10 "2021-01-27T18:37:46Z")

</div>

no, it means his/her code is wrong.

---

<div class="post-metadata">

**Author:** ![Luke10](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/luke10/32/19892_2.png) [@Luke10](https://discourse.codecombat.com/u/Luke10)\
**Post date:** [January 27, 2021, 7:16pm UTC](https://discourse.codecombat.com/t/python-treasured-in-ice/27050/11 "2021-01-27T19:16:14Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![Cong\_Vinh\_Tran](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/cong_vinh_tran/32/34408_2.png) [@Cong\_Vinh\_Tran](https://discourse.codecombat.com/u/Cong_Vinh_Tran)\
**Post date:** [June 11, 2023, 10:53am UTC](https://discourse.codecombat.com/t/python-treasured-in-ice/27050/12 "2023-06-11T10:53:11Z")

</div>

So to beat treasured in ice, I need a fast hero ?
