Lost Viking level just keep hitting fire-traps

So. I think I have written this well, if not a little over-complicated. Everything seems to be working as it should but I still run into a fire-trap. Below is my code; any help would be appreciated…

# The raven will tell you what to use for your maze parameters!
slide = 9
switch = 5
skip = 7
# How many sideSteps north of the Red X you've taken.
sideSteps = 1

# How many steps east of the Red X you've taken.
steps = 1

# Multiply this with steps to determine your X coordinate. DON'T CHANGE THIS!
X_PACE_LENGTH = 4

# Multiply this with sideSteps to determine your Y coordinate. DON'T CHANGE THIS!
Y_PACE_LENGTH = 6

switchLoop = 1
loopCounter = 0
        
# The maze is 35 steps along the X axis.
while steps <= 35:
    
    # Take the next step:
    
    while True:
        self.say(steps)
        if switchLoop % 2 == 1:
            steps += 1
            sideSteps += 1
            hero.moveXY(steps * X_PACE_LENGTH, sideSteps * Y_PACE_LENGTH)
            loopCounter += 1
            if loopCounter == 4:
                switchLoop += 1
                break
        else:
            steps += 1
            sideSteps -= 1
            hero.moveXY(steps * X_PACE_LENGTH, sideSteps * Y_PACE_LENGTH)
            loopCounter += 1
            if loopCounter == 4:
                switchLoop += 1
                break
        
        if steps % switch == 0:
            if switchLoop % 2 == 1:
                
                steps += 1
                sideSteps -= 1
                hero.moveXY(steps * X_PACE_LENGTH, sideSteps * Y_PACE_LENGTH)
                loopCounter += 1
                if loopCounter == 4:
                    switchLoop += 1
                    self.say(switchLoop)
                    break
                
            elif switchLoop % 2 == 0:    
                
                steps += 1
                sideSteps += 1
                hero.moveXY(steps * X_PACE_LENGTH, sideSteps * Y_PACE_LENGTH)
                loopCounter += 1
                if loopCounter == 4:
                    switchLoop += 1
                    self.say(switchLoop)
                    break
        
        elif steps % skip == 0:
            hero.say("skip")
            steps += 1
            sideSteps += 1
            hero.moveXY(steps * X_PACE_LENGTH, sideSteps * Y_PACE_LENGTH)
        
        elif steps % slide == 0:
            hero.say("slide")
            while True:
                if sideSteps > 1:
                    steps += 0
                    sideSteps -= 1
                    hero.moveXY(steps * X_PACE_LENGTH, sideSteps * Y_PACE_LENGTH)
                else:
                    break

Okay. I just simplified it and it still runs me into a fire-trap:

# You MUST click on the HELP button to see a detailed description of this level!

# The raven will tell you what to use for your maze parameters!
slide = 9
switch = 5
skip = 7
# How many sideSteps north of the Red X you've taken.
sideSteps = 1

# How many steps east of the Red X you've taken.
steps = 1

# Multiply this with steps to determine your X coordinate. DON'T CHANGE THIS!
X_PACE_LENGTH = 4

# Multiply this with sideSteps to determine your Y coordinate. DON'T CHANGE THIS!
Y_PACE_LENGTH = 6

switchLoop = 1
loopCounter = 0
        
# The maze is 35 steps along the X axis.
while steps <= 35:
    
    # Take the next step:
    
    while True:
        self.say(steps)
        if switchLoop % 2 == 1:
            steps += 1
            sideSteps += 1
            hero.moveXY(steps * X_PACE_LENGTH, sideSteps * Y_PACE_LENGTH)
            loopCounter += 1
            if loopCounter == 4:
                switchLoop += 1
                break
        else:
            steps += 1
            sideSteps -= 1
            hero.moveXY(steps * X_PACE_LENGTH, sideSteps * Y_PACE_LENGTH)
            loopCounter += 1
            if loopCounter == 4:
                switchLoop += 1
                break
        
        if steps % switch == 0:
             switchLoop += 1
        
        elif steps % skip == 0:
            hero.say("skip")
            steps += 1
            sideSteps += 2
            hero.moveXY(steps * X_PACE_LENGTH, sideSteps * Y_PACE_LENGTH)
        
        elif steps % slide == 0:
            hero.say("slide")
            while True:
                if sideSteps > 1:
                    steps += 0
                    sideSteps -= 1
                    hero.moveXY(steps * X_PACE_LENGTH, sideSteps * Y_PACE_LENGTH)
                else:
                    break

    

Welcome to the forum @thomasknauer! :partying_face: This is a friendly place where you can ask help on levels, report bugs, or just chat with other coders! Don’t forget to read the guidelines if you haven’t yet. Have a great time!

I think you don’t need a while-true loop inside the other while loop (the one below)

And this can be merged into one line, or one while loop:

Hope this helps :slight_smile:
And please post your new code if you run it and it still doesn’t work.

1 Like