# CS6 15 Treasured In Ice Level Help

**URL:** <https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828>\
**Category:** Level Help\
**Created:** [July 16, 2023, 6:43am UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828 "2023-07-16T06:43:59Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tsaibow](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tsaibow/32/34691_2.png) [@Tsaibow](https://discourse.codecombat.com/u/Tsaibow)\
**Post date:** [July 16, 2023, 6:44am UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828/1 "2023-07-16T06:44:00Z")

</div>

Hello, here comes some errors about types during I write the code. I have been searching for the solution for a few months, but still couldn’t get the solution😭. Here is my code:

exitPosition = {“x”: 150, “y”: 120}  
distanceBetweenRooms = 16  
zeroShift = {“x”: 10, “y”: 10}

inSearch = True  
width = 19  
height = 15

def coorConvert(i, dist):  
return i \* distanceBetweenRooms / 2 + zeroShift.x

wall = “X”  
unknown = “?”  
empty = “.”

maze =

for i in range(height):  
maze.append([wall])

for i in range(height):  
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)

def checkPaths(cMap):  
cMap[hero.row][hero.col] = “.”  
dirs = [[1, 0, north], [-1, 0, south], [0, 1, west], [0, -1, east]]  
for d in range(len(dirs)):  
dx = dirs[d][0]  
dy = dirs[d][1]  
dPosFunc = dirs[d][2]  
if (cMap[hero.row+dx][hero.col+dy] == “?”  
and hero.isPathClear(hero.pos, dPosFunc())):  
cMap[hero.row+dx][hero.col+dy] = “.”  
return cMap

def findPath(m, needExit):  
stack = [[hero.row, hero.col, “”]]  
visited =   
index = 0  
while len(stack):  
current = stack[index]  
index += 1  
row = current[0]  
col = current[1]  
path = current[2]  
data = m[row-1][col] + " "  
strPos = row + “-” + col  
if visited.indexOf(strPos) != 1:  
continue  
visited.append(strPos)  
if not needExit and m[row][col] == “?”:  
return path  
if needExit and row == exitRow and col == exitCol:  
return path + “!”  
if m[row-1][col] == “.”:  
stack.append([row-2, col, path + “S”])  
if m[row+1][col] == “.”:  
stack.append([row+2, col, path + “N”])  
if m[row][col+1] == “.”:  
stack.append([row, col + 2, path + “W”])  
if m[row][col-1] == “.”:  
stack.append([row, col - 2, path + “E”])  
for p in range(len(path)):  
moveDir(path[p])

def moveDir(direction):  
newPosFunc = {  
“N” : north,  
“S” : south,  
“E” : east,  
“W” : west,  
“!” : exit  
}[direction]  
newPos = newPosFunc()  
hero.moveXY(newPos.x, newPos.y)  
if direction == “!”:  
inSearch = False  
hero.row = newPos.row  
hero.col = newPos.col

def east():  
return {“x” : coorConvert(hero.col - 2),  
“y” : coorConvert(hero.row),  
“row” : hero.row, “col” : hero.col - 2}

def west():  
return {“x” : coorConvert(hero.col + 2),  
“y” : coorConvert(hero.row),  
“row” : hero.row, “col” : hero.col + 2}

def south():  
return {“x” : coorConvert(hero.col),  
“y” : coorConvert(hero.row - 2),  
“row” : hero.row - 2, “col” : hero.col}

def north():  
return {“x” : coorConvert(hero.col),  
“y” : coorConvert(hero.row + 2),  
“row” : hero.row + 2, “col” : hero.col}

def exit():  
return exitPosition

path = “”  
treasureFound = False

while inSearch:  
maze = checkPaths(maze)  
if hero.gold \> 0:  
treasureFound = True  
inSearch = False  
path = findPath(maze, treasureFound)  
if not path:  
pass  
else:  
for p in range(len(path)):  
moveDir(path[p])

---

<div class="post-metadata">

**Author:** ![Arthur\_U](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/arthur_u/32/33846_2.png) [@Arthur\_U](https://discourse.codecombat.com/u/Arthur_U)\
**Post date:** [July 17, 2023, 2:37am UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828/2 "2023-07-17T02:37:44Z")

</div>

Welcome to the codecombat discourse! a place to talk about code combat and code a cozy chatting place maybe! by the way when asking for solutions please format your code with the \</\> button

---

<div class="post-metadata">

**Author:** ![Tsaibow](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tsaibow/32/34691_2.png) [@Tsaibow](https://discourse.codecombat.com/u/Tsaibow)\
**Post date:** [July 17, 2023, 12:32pm UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828/3 "2023-07-17T12:32:31Z")

</div>

[quote=“Tsaibow, post:1, topic:35828, full:true”]  
Hello, here comes some errors about types during I write the code. I have been searching for the solution for a few months, but still couldn’t get the solution😭. Here is my code:

```python
exitPosition = {“x”: 150, “y”: 120}
distanceBetweenRooms = 16
zeroShift = {“x”: 10, “y”: 10}

inSearch = True
width = 19
height = 15

def coorConvert(i, dist):
return i * distanceBetweenRooms / 2 + zeroShift.x

wall = “X”
unknown = “?”
empty = “.”

maze =

for i in range(height):
maze.append([wall])

for i in range(height):
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)

def checkPaths(cMap):
cMap[hero.row][hero.col] = “.”
dirs = [[1, 0, north], [-1, 0, south], [0, 1, west], [0, -1, east]]
for d in range(len(dirs)):
dx = dirs[d][0]
dy = dirs[d][1]
dPosFunc = dirs[d][2]
if (cMap[hero.row+dx][hero.col+dy] == “?”
and hero.isPathClear(hero.pos, dPosFunc())):
cMap[hero.row+dx][hero.col+dy] = “.”
return cMap

def findPath(m, needExit):
stack = [[hero.row, hero.col, “”]]
visited =
index = 0
while len(stack):
current = stack[index]
index += 1
row = current[0]
col = current[1]
path = current[2]
data = m[row-1][col] + " "
strPos = row + “-” + col
if visited.indexOf(strPos) != 1:
continue
visited.append(strPos)
if not needExit and m[row][col] == “?”:
return path
if needExit and row == exitRow and col == exitCol:
return path + “!”
if m[row-1][col] == “.”:
stack.append([row-2, col, path + “S”])
if m[row+1][col] == “.”:
stack.append([row+2, col, path + “N”])
if m[row][col+1] == “.”:
stack.append([row, col + 2, path + “W”])
if m[row][col-1] == “.”:
stack.append([row, col - 2, path + “E”])
for p in range(len(path)):
moveDir(path[p])

def moveDir(direction):
newPosFunc = {
“N” : north,
“S” : south,
“E” : east,
“W” : west,
“!” : exit
}[direction]
newPos = newPosFunc()
hero.moveXY(newPos.x, newPos.y)
if direction == “!”:
inSearch = False
hero.row = newPos.row
hero.col = newPos.col

def east():
return {“x” : coorConvert(hero.col - 2),
“y” : coorConvert(hero.row),
“row” : hero.row, “col” : hero.col - 2}

def west():
return {“x” : coorConvert(hero.col + 2),
“y” : coorConvert(hero.row),
“row” : hero.row, “col” : hero.col + 2}

def south():
return {“x” : coorConvert(hero.col),
“y” : coorConvert(hero.row - 2),
“row” : hero.row - 2, “col” : hero.col}

def north():
return {“x” : coorConvert(hero.col),
“y” : coorConvert(hero.row + 2),
“row” : hero.row + 2, “col” : hero.col}

def exit():
return exitPosition

path = “”
treasureFound = False

while inSearch:
maze = checkPaths(maze)
if hero.gold > 0:
treasureFound = True
inSearch = False
path = findPath(maze, treasureFound)
if not path:
pass
else:
for p in range(len(path)):
moveDir(path[p])

```

---

<div class="post-metadata">

**Author:** ![Arthur\_U](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/arthur_u/32/33846_2.png) [@Arthur\_U](https://discourse.codecombat.com/u/Arthur_U)\
**Post date:** [July 18, 2023, 10:37am UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828/4 "2023-07-18T10:37:21Z")

</div>

> maze =  
> First error i see gotta check more code

also because you formatted the same unformatted code even when formated its well wrong

---

<div class="post-metadata">

**Author:** ![Tsaibow](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tsaibow/32/34691_2.png) [@Tsaibow](https://discourse.codecombat.com/u/Tsaibow)\
**Post date:** [July 18, 2023, 11:10am UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828/5 "2023-07-18T11:10:39Z")

</div>

Thanks for the tip. I will make it better

```python
exitPosition = {“x”: 150, “y”: 120}
distanceBetweenRooms = 16
zeroShift = {“x”: 10, “y”: 10}

inSearch = True
width = 19
height = 15

def coorConvert(i, dist):
    return i * distanceBetweenRooms / 2 + zeroShift.x

wall = “X”
unknown = “?”
empty = “.”

maze =[]

for i in range(height):
    maze.append([wall])

for i in range(height):
    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)

def checkPaths(cMap):
    cMap[hero.row][hero.col] = “.”
    dirs = [[1, 0, north], [-1, 0, south], [0, 1, west], [0, -1, east]]
    for d in range(len(dirs)):
        dx = dirs[d][0]
        dy = dirs[d][1]
        dPosFunc = dirs[d][2]
        if (cMap[hero.row+dx][hero.col+dy] == “?”
            and hero.isPathClear(hero.pos, dPosFunc())):
            cMap[hero.row+dx][hero.col+dy] = “.”
    return cMap

def findPath(m, needExit):
    stack = [[hero.row, hero.col, “”]]
    visited =[]
    index = 0
    while len(stack):
        current = stack[index]
        index += 1
        row = current[0]
        col = current[1]
        path = current[2]
        data = m[row-1][col] + " "
        strPos = row + “-” + col
        if visited.indexOf(strPos) != 1:
            continue
        visited.append(strPos)
        if not needExit and m[row][col] == “?”:
                return path
        if needExit and row == exitRow and col == exitCol:
                return path + “!”
        if m[row-1][col] == “.”:
                stack.append([row-2, col, path + “S”])
        if m[row+1][col] == “.”:
                stack.append([row+2, col, path + “N”])
        if m[row][col+1] == “.”:
                stack.append([row, col + 2, path + “W”])
        if m[row][col-1] == “.”:
                stack.append([row, col - 2, path + “E”])

    for p in range(len(path)):
        moveDir(path[p])

def moveDir(direction):
    newPosFunc = {
        “N” : north,
        “S” : south,
        “E” : east,
        “W” : west,
        “!” : exit
    }[direction]
    newPos = newPosFunc()
    hero.moveXY(newPos.x, newPos.y)
    if direction == “!”:
        inSearch = False
    hero.row = newPos.row
    hero.col = newPos.col

def east():
    return {“x” : coorConvert(hero.col - 2),
        “y” : coorConvert(hero.row),
        “row” : hero.row, “col” : hero.col - 2}

def west():
    return {“x” : coorConvert(hero.col + 2),
        “y” : coorConvert(hero.row),
        “row” : hero.row, “col” : hero.col + 2}

def south():
    return {“x” : coorConvert(hero.col),
        “y” : coorConvert(hero.row - 2),
        “row” : hero.row - 2, “col” : hero.col}

def north():
    return {“x” : coorConvert(hero.col),
        “y” : coorConvert(hero.row + 2),
        “row” : hero.row + 2, “col” : hero.col}

def exit():
    return exitPosition

path = “”
treasureFound = False

while inSearch:
    maze = checkPaths(maze)
    if hero.gold > 0:
        treasureFound = True
        inSearch = False
    path = findPath(maze, treasureFound)
    if not path:
        pass
    else:
        for p in range(len(path)):
            moveDir(path[p])

```

---

<div class="post-metadata">

**Author:** ![Arthur\_U](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/arthur_u/32/33846_2.png) [@Arthur\_U](https://discourse.codecombat.com/u/Arthur_U)\
**Post date:** [July 18, 2023, 11:15am UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828/6 "2023-07-18T11:15:11Z")

</div>

because i havent exactly played this lvl could you send me the link of it?

---

<div class="post-metadata">

**Author:** ![Tsaibow](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tsaibow/32/34691_2.png) [@Tsaibow](https://discourse.codecombat.com/u/Tsaibow)\
**Post date:** [July 18, 2023, 12:41pm UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828/7 "2023-07-18T12:41:53Z")

</div>

Hi, this is the link of the level.

[https://reurl.cc/XE95GE](https://reurl.cc/XE95GE)

---

<div class="post-metadata">

**Author:** ![Arthur\_U](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/arthur_u/32/33846_2.png) [@Arthur\_U](https://discourse.codecombat.com/u/Arthur_U)\
**Post date:** [July 19, 2023, 3:20am UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828/8 "2023-07-19T03:20:48Z")

</div>

thanks well since i use a course subscription too i cant exactly help you other than try and debug the code so… @moonwatcher348 and @PeterPalov maybe you guys can help a bit?

---

<div class="post-metadata">

**Author:** ![Arthur\_U](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/arthur_u/32/33846_2.png) [@Arthur\_U](https://discourse.codecombat.com/u/Arthur_U)\
**Post date:** [July 19, 2023, 3:21am UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828/9 "2023-07-19T03:21:22Z")

</div>

the reason i cant is im stll saving too actually buy another subscription so so far i need some time before i can help you

---

<div class="post-metadata">

**Author:** ![Arthur\_U](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/arthur_u/32/33846_2.png) [@Arthur\_U](https://discourse.codecombat.com/u/Arthur_U)\
**Post date:** [July 19, 2023, 3:22am UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828/10 "2023-07-19T03:22:47Z")

</div>

IN the meantime ill be checking the code in a code editor

---

<div class="post-metadata">

**Author:** ![Tsaibow](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tsaibow/32/34691_2.png) [@Tsaibow](https://discourse.codecombat.com/u/Tsaibow)\
**Post date:** [July 19, 2023, 10:39am UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828/11 "2023-07-19T10:39:12Z")

</div>

Thank you for your help!!! 😂

---

<div class="post-metadata">

**Author:** ![Arthur\_U](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/arthur_u/32/33846_2.png) [@Arthur\_U](https://discourse.codecombat.com/u/Arthur_U)\
**Post date:** [July 20, 2023, 7:47am UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828/12 "2023-07-20T07:47:52Z")

</div>

np this is the first time ive been useful to someone with code issues

---

<div class="post-metadata">

**Author:** ![Tsaibow](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tsaibow/32/34691_2.png) [@Tsaibow](https://discourse.codecombat.com/u/Tsaibow)\
**Post date:** [July 20, 2023, 11:26am UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828/13 "2023-07-20T11:26:19Z")

</div>

really???  
you look like an expert🎓

---

<div class="post-metadata">

**Author:** ![Arthur\_U](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/arthur_u/32/33846_2.png) [@Arthur\_U](https://discourse.codecombat.com/u/Arthur_U)\
**Post date:** [July 21, 2023, 4:38am UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828/14 "2023-07-21T04:38:44Z")

</div>

nah i pretty much am bad at this i do more normal like real python more im better at that but ill try to do as much as possible to help

---

<div class="post-metadata">

**Author:** ![Arthur\_U](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/arthur_u/32/33846_2.png) [@Arthur\_U](https://discourse.codecombat.com/u/Arthur_U)\
**Post date:** [July 21, 2023, 4:39am UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828/15 "2023-07-21T04:39:35Z")

</div>

@MarmiteOnToast could you help please?

---

<div class="post-metadata">

**Author:** ![Tsaibow](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tsaibow/32/34691_2.png) [@Tsaibow](https://discourse.codecombat.com/u/Tsaibow)\
**Post date:** [July 23, 2023, 10:35am UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828/16 "2023-07-23T10:35:03Z")

</div>

It seems that the problem is here:

 ![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/0/a/0a4a43dfaf97e7112d11ec182774df7f851de16f.jpeg)

---

<div class="post-metadata">

**Author:** ![MarmiteOnToast](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/marmiteontoast/32/46649_2.png) [@MarmiteOnToast](https://discourse.codecombat.com/u/MarmiteOnToast)\
**Post date:** [July 23, 2023, 3:03pm UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828/17 "2023-07-23T15:03:08Z")

</div>

Hulloo  
I’ll do my best to assist Tsaibow and yourself with any issues you encounter on [CodeCombat - Coding games to learn Python and JavaScript](https://codecombat.com/play/level/treasured-in-ice)  
(I apologise for the late response)

---

<div class="post-metadata">

**Author:** ![Arthur\_U](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/arthur_u/32/33846_2.png) [@Arthur\_U](https://discourse.codecombat.com/u/Arthur_U)\
**Post date:** [July 24, 2023, 1:55am UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828/18 "2023-07-24T01:55:53Z")

</div>

finally ive never done this so i appreciete

---

<div class="post-metadata">

**Author:** ![Arthur\_U](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/arthur_u/32/33846_2.png) [@Arthur\_U](https://discourse.codecombat.com/u/Arthur_U)\
**Post date:** [July 24, 2023, 1:56am UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828/19 "2023-07-24T01:56:43Z")

</div>

ok so it means it cant use the non object type i guess? in some way

---

<div class="post-metadata">

**Author:** ![Tsaibow](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tsaibow/32/34691_2.png) [@Tsaibow](https://discourse.codecombat.com/u/Tsaibow)\
**Post date:** [July 24, 2023, 4:19am UTC](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828/20 "2023-07-24T04:19:17Z")

</div>

yes but i really dont know how to solve it

[Next page](https://discourse.codecombat.com/t/cs6-15-treasured-in-ice-level-help/35828.md?page=2)
