What's wrong with my level 13 solution? ( "stick to left side" implementation attempt)

1. I think a stick to left side implementation of this problim is not possible. If you want to stick to the left side you have to know where the left side is. So yout have to know what the direction of your last move was. Since the variables of the function

'behavior': function (me) {...}

"reset" every time the function gets called, this is not easy to implement.

EDIT: See comment section.

2. You are only setting the value of direction when x = 1 and y = 1 so it only deos something if those coords are right. Since the robot moves the coords change.

if ( me.getX() == 1 & me.getY() == 1 ){

if ( me.canMove('right') )
    direction = 0;
else
    direction = 1; }

Else direction is unset and nothing will work.

You would change it to the following:

moveRobot( direction ); direction = getDirection();

Note: If you cannot solve a level, don't search for the answers of others, because you will lose the fun of that game. If necessary cheat through and solve the level later:

1. Open console (F12) 2. Enter: "localStorage.levelReached = LEVEL_NUMBER" 3. Reload page