Treasured in ice help (python)

so my hero is just standing there and i really don’t know what im doing wrong. there are no errors in the code, she just isnt moving :confused: also i used some of the code from fragile maze.

# 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}
distanceBetweenRooms = 16
zeroShift = {"x": 10, "y": 10}
directions = ["left", "up", "right", "down"]
corrDir = {
    "up": "left",
    "left": "down",
    "down": "right",
    "right": "up"}
visited = []

def findNextDirection(current):
    return directions[(directions.indexOf(current) + 1) % 4]

def pointInDirection(direction, pos):
    if direction == "left":
        return Vector(pos.x - distanceBetweenRooms, pos.y)
    elif direction == "right":
        return Vector(pos.x + distanceBetweenRooms, pos.y)
    elif direction == "down":
        return Vector(pos.x, pos.y - distanceBetweenRooms)
    elif direction == "up":
        return Vector(pos.x, pos.y + distanceBetweenRooms)

prev = "up"

while True:
    tryDir = corrDir[prev]
    while True:
        tryPoint = pointInDirection(tryDir, hero.pos)
        for visit in visited:
            if visit == tryPoint:
                findNextDirection(tryDir)
            elif visit != tryPoint:
                if hero.isPathClear(hero.pos, tryPoint):
                    treasure = hero.findNearestItem()
                    if treasure:
                        hero.moveXY(treasure.pos.x, treasure.pos.y)
                        hero.moveXY(exitPosition)
                    else:
                        hero.moveXY(tryPoint.x, tryPoint.y)
                        hero.moveXY(tryPoint.x, tryPoint.y)
                        visited.append(tryPoint)
                        break
                tryDir = findNextDirection(tryDir)

Try to use flags maybe :slight_smile:

im not really sure what you mean by flags

You can’t use flags in this level (20 chars agrees)

Hmm, I beat this level with flags and somehow they allow for me. Just use pickUpFlag(flag)

Are you sure? Kelvintaph and then treasured in ice?
I get this:


Flags are restricted… (and no I don’t have the pink flag, but I’m betting it’s restricted too)

im using codecombat for a programming class, so i only get whats allowed during the course. i havent learned about flags, either. also, i ended up getting the answer from my teacher, but i wanted to be able to work it out myself

Yes, it’s in kelvintaph. Kinda did a little “hack” in console to make it work. :stuck_out_tongue_winking_eye:

1 Like

uh i dont think ive done kelvintaph. it doesnt ring any bells

yeah i clicked the link @moonwatcher348 provided and it comes up as an error. i dont think it will open up for me since i have a specific course to take

I would have done the same but I can’t use console lol

Yeah, you’re using the class version of CodeCombat

Kelvintaph is basically cs6