Skip to content

Instantly share code, notes, and snippets.

@vojto
Created March 13, 2010 22:06
Show Gist options
  • Save vojto/331588 to your computer and use it in GitHub Desktop.
Save vojto/331588 to your computer and use it in GitHub Desktop.
=#define STEP_DELAY 50
void turnRight();
void turnAround();
int moveUntilWall();
void moveToCenter();
int main() {
turnOn("middleearth2.kw");
setStepDelay(STEP_DELAY);
moveToCenter();
turnLeft();
moveToCenter();
turnOff();
}
void moveToCenter() {
moveUntilWall();
turnAround();
int worldSize = moveUntilWall();
turnAround();
int center = worldSize/2;
while(center--) {
movek();
}
}
int moveUntilWall() {
int distanceMade = 0;
while(frontIsClear()) {
distanceMade++;
movek();
}
return distanceMade;
}
void turnRight() {
setStepDelay(0);
turnLeft();
turnLeft();
turnLeft();
setStepDelay(STEP_DELAY);
}
void turnAround() {
setStepDelay(0);
turnLeft();
turnLeft();
setStepDelay(STEP_DELAY);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment