Lost Viking - Raven?

So the Raven will always say what the actual steps/sideSteps are -1.

In order for me to know the exact steps I was actually taking, I had to do:
hero.say("steps is " + steps);
hero.say("sideSteps is " + sideSteps);

since the raven isn’t quoting the actual steps but is a step behind. It’s confusing

OR am I missing something?

You can test and recreate it with this code:

Code
// 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!
var SLIDE = 9;
var SKIP = 7;
var SWITCH = 5;

// How many sideSteps north of the Red X you've taken.
var sideSteps = 1;
// How many steps east of the Red X you've taken.
var steps = 1;



// Multiply this with steps to determine your X coordinate. DON'T CHANGE THIS!
var X_PACE_LENGTH = 4;
// Multiply this with sideSteps to determine your Y coordinate. DON'T CHANGE THIS!
var Y_PACE_LENGTH = 6;

var direction = 1;

// The maze is 35 steps along the X axis.
while (steps <= 35) {
    // Take the next step:
    hero.moveXY(steps * X_PACE_LENGTH, sideSteps * Y_PACE_LENGTH);
    // Increment steps and sideSteps as appropriate, taking into account the special rules.

    steps += 1;
    sideSteps += direction;

    hero.say("steps is " + steps);  
    hero.say("sideSteps is " + sideSteps);  
}

[EDIT]

You’re right SuperSmacker! Thanks for the help! I’m still learning how the order of programming executes. Good to know I can confidently quote the raven :slight_smile:

You incremented the step before saying it. You are saying the number of steps BEFORE you take the next step. For example, at the beginning, you said steps = 2 even though you didn’t even move yet. The raven says the number of steps you have taken when you are talking about the number of steps you are about to take.

Therefore, the raven is not bugged.

Does that answer your question?

1 Like

So I moved the hero.say() before the increments, however, the hero doesn’t take a step until saying steps = 2. Here’s what I have so far:

Code so far on Lost Viking
// 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!
var SLIDE = 9;
var SKIP = 7;
var SWITCH = 5;

// How many sideSteps north of the Red X you've taken.
var sideSteps = 1;
// How many steps east of the Red X you've taken.
var steps = 1;



// Multiply this with steps to determine your X coordinate. DON'T CHANGE THIS!
var X_PACE_LENGTH = 4;
// Multiply this with sideSteps to determine your Y coordinate. DON'T CHANGE THIS!
var Y_PACE_LENGTH = 6;

var direction = 1;

// The maze is 35 steps along the X axis.
while (steps <= 35) {

//Checking for various maze parameters
    var yesSwitch = (steps) % SWITCH === 0;
    var yesSkip = (steps) % SKIP === 0;
    var yesSlide1 = (sideSteps > 10);
    var yesSlide10 = (sideSteps < 3 && steps > 2); 
    
    hero.say("steps is " + steps);  
    hero.say("sideSteps is " + sideSteps);  
    hero.say("yesSwitch is " + yesSwitch);    
    hero.say("yesSkip is " + yesSkip);
    hero.say("yesSlide1 is " + yesSlide1);
    hero.say("yesSlide10 is " + yesSlide10);
    
    // Take the next step:
    hero.moveXY(steps * X_PACE_LENGTH, sideSteps * Y_PACE_LENGTH);
    // Increment steps and sideSteps as appropriate, taking into account the special rules.

    if (yesSwitch) {
        direction = -direction;
    } else if (yesSlide10) {
        sideSteps = 10;
    } else if (yesSlide1) {
        sideSteps = 1;
    }
    steps += 1;
    sideSteps += direction;
}

Format it please :frowning: i can’t read that

1 Like

Done - it’s above your previous comment.

What is “Slide1”? Also your code is very confusing.

Where you defined the maze parameters is probably where everything went wrong. I have no idea what you are doing by defining those variables.

I’m breaking down the problem by creating variables.

The purpose of the Slide 1 variable is to check if it’s true. If it is true (if sidesteps > 10) then move on the y-axis by 1.

Also, by storing it in a variable, I can check every time the hero moves with hero.say(); to make sure my code is doing what I want it to do.

I see the problem. Right before you blow up you said yesSkip = True but u didn’t do anything even though it’s true.

Here I tweaked the code a bit. It’s now usable until the up and down part. That’s where everything goes wrong. I think 2 conditions over lap over there. Both the slide and the switch thing. And stuff goes wrong.

@Chaboi_3000 can you take a look at this and help out @Eric_Kidwell for me? I’m completely out of brainpower. I could write a code out of scratch faster and less painful than fixing up the current one, but that wouldn’t be educational.

Anyway, @Chaboi_3000 if you decide to help, thanks in advance.

Here’s the code I have after tweaking:

Totally not a troll
// 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!
var SLIDE = 10;
var SKIP = 11;
var SWITCH = 7;

// How many sideSteps north of the Red X you've taken.
var sideSteps = 1;
// How many steps east of the Red X you've taken.
var steps = 1;



// Multiply this with steps to determine your X coordinate. DON'T CHANGE THIS!
var X_PACE_LENGTH = 4;
// Multiply this with sideSteps to determine your Y coordinate. DON'T CHANGE THIS!
var Y_PACE_LENGTH = 6;

var direction = 1;

// The maze is 35 steps along the X axis.
while (steps <= 35) {
    var yesSwitch = (steps) % SWITCH === 0;
    var yesSkip = (steps) % SKIP === 0;
    var yesSlide1 = (sideSteps > 9);
    var yesSlide10 = (sideSteps < 2 && steps > 1);
    // Take the next step:
    // Increment steps and sideSteps as appropriate, taking into account the special rules.
    steps += 1;
    if (yesSwitch) {
        direction = -direction;
    }
    if (yesSkip) {
        sideSteps += 2 * direction;
    }
    if (yesSlide10) {
        sideSteps = 10;
    }
    if (yesSlide1) {
        sideSteps = 1;
    }
    if (! yesSkip && ! yesSlide10 && ! yesSlide1){
        sideSteps += direction;
    }
    hero.moveXY(steps * X_PACE_LENGTH, sideSteps * Y_PACE_LENGTH);
}

It seems like, codecombat has to edit the hints. You need to tweak and figure out your own slide skip and switch numbers. ;(