Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
//generating random steps
for(i =0; i<10; i++){
function randsteps(){
direction = "";
r = random();
if (r < 0.25)
direction = "right";
else if (r < 0.5)
direction = "up";
else if (r < 0.75)
direction = "left";
direction= "down";
return direction;

This comment has been minimized.

Copy link
Owner Author

miura commented May 16, 2013

This macro demonstrates how to choose four directions randomly.
The function "randomsteps()" is the key user-defined function. Line 8 generates a randome number between 0 and 1, and depending on its value, one of four directions is returned from the funciton.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.