Skip to content

Instantly share code, notes, and snippets.

@crabdancing
Created November 15, 2018 23:47
Show Gist options
  • Save crabdancing/0e003f39956cecce4c57d3511beb19bf to your computer and use it in GitHub Desktop.
Save crabdancing/0e003f39956cecce4c57d3511beb19bf to your computer and use it in GitHub Desktop.
Random Walk
# Copyleft (C) Alexandria Pettit GNU GPLv3
# Very very crude random walk program.
# For use with NXT-powered robots with standard motor to port wiring.
task main()
{
while (true) {
switch (Random(3)) {
case 0:
OnFwd(OUT_C, 100);
OnFwd(OUT_B, 100);
break;
case 1:
OnFwd(OUT_C, 100);
OnFwd(OUT_B, -100);
break;
case 2:
OnFwd(OUT_C, -100);
OnFwd(OUT_B, 100);
break;
case 3:
OnFwd(OUT_C, -100);
OnFwd(OUT_B, -100);
break;
}
Wait(1000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment