Untrusted - level 13 - what's wrong with my solution? ( “stick to left side” implementation attempt)Level 10 with droidsHelp with Level 16's lazers

Are there reliable, formulaic ways to form chords on the guitar?

Why is the name Bergson pronounced like Berksonne?

Installing certbot - error - "nothing provides pyparsing"

9 hrs long transit in DEL

Why was ramjet fuel used as hydraulic fluid during Saturn V checkout?

What is bodily formation? Does it refer to the breath or the body?

Output with the same length always

What is "super" in superphosphate?

What is the evidence on the danger of feeding whole blueberries and grapes to infants and toddlers?

Inset Square From a Rectangular Face

Playing a fast but quiet Alberti bass

Land Registry Clause

Unsolved Problems due to Lack of Computational Power

How to detect a failed AES256 decryption programmatically?

Chess software to analyze games

Levenshtein Neighbours

Can the front glass be repaired of a broken lens?

!I!n!s!e!r!t! !b!e!t!w!e!e!n!

Did Wernher von Braun really have a "Saturn V painted as the V2"?

Installing the original OS X version onto a Mac?

Sinc interpolation in spatial domain

What's the point of writing that I know will never be used or read?

Does the Temple of the Gods spell nullify critical hits?

Expand def in write18



Untrusted - level 13 - what's wrong with my solution? ( “stick to left side” implementation attempt)


Level 10 with droidsHelp with Level 16's lazers






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















So I'm struggling with this game as a (super fun!) homework. I got stuck at level 13, after 2 hours I glanced at the other topic about it and tried to implement "stick to the left side" method, but it doesn't seem to work.



Could you guys tell me what's wrong? There might be some pretty fundamental mistakes as my first encounter with JavaScript was on Tuesday.



var direction;

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

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


moveRobot( direction );
direction = getDirection();

function moveRobot( direction )

if ( me.canMove( getDirectionName( direction ) ) )
me.move( getDirectionName( direction ) ) ;

else if ( !me.canMove( getDirectionName( direction ) )
& me.canMove( getDirectionName( (direction + 1) % 4) ) )
me.move( getDirectionName( (direction + 1) % 4) );
direction = (direction + 1) % 4;

else
me.move( getDirectionName( (direction + 2) % 4) );
direction = (direction + 2) % 4;




function getDirection( )

if ( me.canMove( getDirectionName( direction ) ) )
return direction;

else if ( !me.canMove( getDirectionName( direction ) )
& me.canMove( getDirectionName( (direction + 1) % 4) ) )
return (direction + 1) % 4;

else
return (direction + 2) % 4;


function getDirectionName( direction )

if ( direction == 0 )
return 'right';
else if ( direction == 1 )
return 'down';
else if ( direction == 2 )
return 'left';
else
return 'up';










share|improve this question

















bumped to the homepage by Community 1 hour ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • This is on-topic on Stack Overflow.

    – Anthony Pham
    Nov 12 '15 at 0:15






  • 1





    @PythonMaster, just to clarify, this is still on topic, here. While StackOverflow can help you with just about any programming-related issue, we still consider it on topic when the problem is also game-related. If you need to solve the programming issue to progress in the game, it is most certainly game-related. vim-adventures is another example of a code-based game

    – user106385
    Nov 12 '15 at 0:31











  • @PythonMaster I thought that this question is difficult to be stated on Stack Overflow properly. After all you need to play this game to be able to see what's inside level 13.

    – ltw
    Nov 12 '15 at 0:38











  • Oh, it's a game... Wish I could retract my downvote...

    – Anthony Pham
    Nov 12 '15 at 0:39






  • 1





    The game is tagged in the question, @PythonMaster. The question still looks like it could do with a tidy edit, once edited you can change your vote

    – user106385
    Nov 12 '15 at 0:54

















1















So I'm struggling with this game as a (super fun!) homework. I got stuck at level 13, after 2 hours I glanced at the other topic about it and tried to implement "stick to the left side" method, but it doesn't seem to work.



Could you guys tell me what's wrong? There might be some pretty fundamental mistakes as my first encounter with JavaScript was on Tuesday.



var direction;

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

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


moveRobot( direction );
direction = getDirection();

function moveRobot( direction )

if ( me.canMove( getDirectionName( direction ) ) )
me.move( getDirectionName( direction ) ) ;

else if ( !me.canMove( getDirectionName( direction ) )
& me.canMove( getDirectionName( (direction + 1) % 4) ) )
me.move( getDirectionName( (direction + 1) % 4) );
direction = (direction + 1) % 4;

else
me.move( getDirectionName( (direction + 2) % 4) );
direction = (direction + 2) % 4;




function getDirection( )

if ( me.canMove( getDirectionName( direction ) ) )
return direction;

else if ( !me.canMove( getDirectionName( direction ) )
& me.canMove( getDirectionName( (direction + 1) % 4) ) )
return (direction + 1) % 4;

else
return (direction + 2) % 4;


function getDirectionName( direction )

if ( direction == 0 )
return 'right';
else if ( direction == 1 )
return 'down';
else if ( direction == 2 )
return 'left';
else
return 'up';










share|improve this question

















bumped to the homepage by Community 1 hour ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • This is on-topic on Stack Overflow.

    – Anthony Pham
    Nov 12 '15 at 0:15






  • 1





    @PythonMaster, just to clarify, this is still on topic, here. While StackOverflow can help you with just about any programming-related issue, we still consider it on topic when the problem is also game-related. If you need to solve the programming issue to progress in the game, it is most certainly game-related. vim-adventures is another example of a code-based game

    – user106385
    Nov 12 '15 at 0:31











  • @PythonMaster I thought that this question is difficult to be stated on Stack Overflow properly. After all you need to play this game to be able to see what's inside level 13.

    – ltw
    Nov 12 '15 at 0:38











  • Oh, it's a game... Wish I could retract my downvote...

    – Anthony Pham
    Nov 12 '15 at 0:39






  • 1





    The game is tagged in the question, @PythonMaster. The question still looks like it could do with a tidy edit, once edited you can change your vote

    – user106385
    Nov 12 '15 at 0:54













1












1








1








So I'm struggling with this game as a (super fun!) homework. I got stuck at level 13, after 2 hours I glanced at the other topic about it and tried to implement "stick to the left side" method, but it doesn't seem to work.



Could you guys tell me what's wrong? There might be some pretty fundamental mistakes as my first encounter with JavaScript was on Tuesday.



var direction;

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

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


moveRobot( direction );
direction = getDirection();

function moveRobot( direction )

if ( me.canMove( getDirectionName( direction ) ) )
me.move( getDirectionName( direction ) ) ;

else if ( !me.canMove( getDirectionName( direction ) )
& me.canMove( getDirectionName( (direction + 1) % 4) ) )
me.move( getDirectionName( (direction + 1) % 4) );
direction = (direction + 1) % 4;

else
me.move( getDirectionName( (direction + 2) % 4) );
direction = (direction + 2) % 4;




function getDirection( )

if ( me.canMove( getDirectionName( direction ) ) )
return direction;

else if ( !me.canMove( getDirectionName( direction ) )
& me.canMove( getDirectionName( (direction + 1) % 4) ) )
return (direction + 1) % 4;

else
return (direction + 2) % 4;


function getDirectionName( direction )

if ( direction == 0 )
return 'right';
else if ( direction == 1 )
return 'down';
else if ( direction == 2 )
return 'left';
else
return 'up';










share|improve this question
















So I'm struggling with this game as a (super fun!) homework. I got stuck at level 13, after 2 hours I glanced at the other topic about it and tried to implement "stick to the left side" method, but it doesn't seem to work.



Could you guys tell me what's wrong? There might be some pretty fundamental mistakes as my first encounter with JavaScript was on Tuesday.



var direction;

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

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


moveRobot( direction );
direction = getDirection();

function moveRobot( direction )

if ( me.canMove( getDirectionName( direction ) ) )
me.move( getDirectionName( direction ) ) ;

else if ( !me.canMove( getDirectionName( direction ) )
& me.canMove( getDirectionName( (direction + 1) % 4) ) )
me.move( getDirectionName( (direction + 1) % 4) );
direction = (direction + 1) % 4;

else
me.move( getDirectionName( (direction + 2) % 4) );
direction = (direction + 2) % 4;




function getDirection( )

if ( me.canMove( getDirectionName( direction ) ) )
return direction;

else if ( !me.canMove( getDirectionName( direction ) )
& me.canMove( getDirectionName( (direction + 1) % 4) ) )
return (direction + 1) % 4;

else
return (direction + 2) % 4;


function getDirectionName( direction )

if ( direction == 0 )
return 'right';
else if ( direction == 1 )
return 'down';
else if ( direction == 2 )
return 'left';
else
return 'up';







untrusted






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 12 '15 at 0:49







ltw

















asked Nov 12 '15 at 0:08









ltwltw

112 bronze badges




112 bronze badges






bumped to the homepage by Community 1 hour ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.









bumped to the homepage by Community 1 hour ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 1 hour ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.














  • This is on-topic on Stack Overflow.

    – Anthony Pham
    Nov 12 '15 at 0:15






  • 1





    @PythonMaster, just to clarify, this is still on topic, here. While StackOverflow can help you with just about any programming-related issue, we still consider it on topic when the problem is also game-related. If you need to solve the programming issue to progress in the game, it is most certainly game-related. vim-adventures is another example of a code-based game

    – user106385
    Nov 12 '15 at 0:31











  • @PythonMaster I thought that this question is difficult to be stated on Stack Overflow properly. After all you need to play this game to be able to see what's inside level 13.

    – ltw
    Nov 12 '15 at 0:38











  • Oh, it's a game... Wish I could retract my downvote...

    – Anthony Pham
    Nov 12 '15 at 0:39






  • 1





    The game is tagged in the question, @PythonMaster. The question still looks like it could do with a tidy edit, once edited you can change your vote

    – user106385
    Nov 12 '15 at 0:54

















  • This is on-topic on Stack Overflow.

    – Anthony Pham
    Nov 12 '15 at 0:15






  • 1





    @PythonMaster, just to clarify, this is still on topic, here. While StackOverflow can help you with just about any programming-related issue, we still consider it on topic when the problem is also game-related. If you need to solve the programming issue to progress in the game, it is most certainly game-related. vim-adventures is another example of a code-based game

    – user106385
    Nov 12 '15 at 0:31











  • @PythonMaster I thought that this question is difficult to be stated on Stack Overflow properly. After all you need to play this game to be able to see what's inside level 13.

    – ltw
    Nov 12 '15 at 0:38











  • Oh, it's a game... Wish I could retract my downvote...

    – Anthony Pham
    Nov 12 '15 at 0:39






  • 1





    The game is tagged in the question, @PythonMaster. The question still looks like it could do with a tidy edit, once edited you can change your vote

    – user106385
    Nov 12 '15 at 0:54
















This is on-topic on Stack Overflow.

– Anthony Pham
Nov 12 '15 at 0:15





This is on-topic on Stack Overflow.

– Anthony Pham
Nov 12 '15 at 0:15




1




1





@PythonMaster, just to clarify, this is still on topic, here. While StackOverflow can help you with just about any programming-related issue, we still consider it on topic when the problem is also game-related. If you need to solve the programming issue to progress in the game, it is most certainly game-related. vim-adventures is another example of a code-based game

– user106385
Nov 12 '15 at 0:31





@PythonMaster, just to clarify, this is still on topic, here. While StackOverflow can help you with just about any programming-related issue, we still consider it on topic when the problem is also game-related. If you need to solve the programming issue to progress in the game, it is most certainly game-related. vim-adventures is another example of a code-based game

– user106385
Nov 12 '15 at 0:31













@PythonMaster I thought that this question is difficult to be stated on Stack Overflow properly. After all you need to play this game to be able to see what's inside level 13.

– ltw
Nov 12 '15 at 0:38





@PythonMaster I thought that this question is difficult to be stated on Stack Overflow properly. After all you need to play this game to be able to see what's inside level 13.

– ltw
Nov 12 '15 at 0:38













Oh, it's a game... Wish I could retract my downvote...

– Anthony Pham
Nov 12 '15 at 0:39





Oh, it's a game... Wish I could retract my downvote...

– Anthony Pham
Nov 12 '15 at 0:39




1




1





The game is tagged in the question, @PythonMaster. The question still looks like it could do with a tidy edit, once edited you can change your vote

– user106385
Nov 12 '15 at 0:54





The game is tagged in the question, @PythonMaster. The question still looks like it could do with a tidy edit, once edited you can change your vote

– user106385
Nov 12 '15 at 0:54










1 Answer
1






active

oldest

votes


















0














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.



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

Hope it helped :)






share|improve this answer

























  • This isn't true; the behavior function gets called with the same object every time, so you can use that object to store data.

    – pppery
    1 hour ago













Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "41"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgaming.stackexchange.com%2fquestions%2f242846%2funtrusted-level-13-whats-wrong-with-my-solution-stick-to-left-side-imp%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














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.



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

Hope it helped :)






share|improve this answer

























  • This isn't true; the behavior function gets called with the same object every time, so you can use that object to store data.

    – pppery
    1 hour ago















0














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.



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

Hope it helped :)






share|improve this answer

























  • This isn't true; the behavior function gets called with the same object every time, so you can use that object to store data.

    – pppery
    1 hour ago













0












0








0







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.



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

Hope it helped :)






share|improve this answer













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.



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

Hope it helped :)







share|improve this answer












share|improve this answer



share|improve this answer










answered May 4 '16 at 19:28









Simon MeuselSimon Meusel

1,0275 silver badges16 bronze badges




1,0275 silver badges16 bronze badges















  • This isn't true; the behavior function gets called with the same object every time, so you can use that object to store data.

    – pppery
    1 hour ago

















  • This isn't true; the behavior function gets called with the same object every time, so you can use that object to store data.

    – pppery
    1 hour ago
















This isn't true; the behavior function gets called with the same object every time, so you can use that object to store data.

– pppery
1 hour ago





This isn't true; the behavior function gets called with the same object every time, so you can use that object to store data.

– pppery
1 hour ago

















draft saved

draft discarded
















































Thanks for contributing an answer to Arqade!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgaming.stackexchange.com%2fquestions%2f242846%2funtrusted-level-13-whats-wrong-with-my-solution-stick-to-left-side-imp%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Sahara Skak | Bilen | Luke uk diar | NawigatsjuunCommonskategorii: SaharaWikivoyage raisfeerer: Sahara26° N, 13° O

The fall designs the understood secretary. Looking glass Science Shock Discovery Hot Everybody Loves Raymond Smile 곳 서비스 성실하다 Defas Kaloolon Definition: To combine or impregnate with sulphur or any of its compounds as to sulphurize caoutchouc in vulcanizing Flame colored Reason Useful Thin Help 갖다 유명하다 낙엽 장례식 Country Iron Definition: A fencer a gladiator one who exhibits his skill in the use of the sword Definition: The American black throated bunting Spiza Americana Nostalgic Needy Method to my madness 시키다 평가되다 전부 소설가 우아하다 Argument Tin Feeling Representative Gym Music Gaur Chicken 일쑤 코치 편 학생증 The harbor values the sugar. Vasagle Yammoe Enstatite Definition: Capable of being limited Road Neighborly Five Refer Built Kangaroo 비비다 Degree Release Bargain Horse 하루 형님 유교 석 동부 괴롭히다 경제력

19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу