Skip to content

Instantly share code, notes, and snippets.

@vojto
Created May 10, 2010 13:47
Show Gist options
  • Save vojto/396051 to your computer and use it in GitHub Desktop.
Save vojto/396051 to your computer and use it in GitHub Desktop.
#include "library.c"
void usage(char *binary_name);
void turnAround();
void goUntilWall();
void putBeepers(int count);
int main(int argc, char **argv) {
if(argc != 2)
{
usage(argv[0]);
exit(1);
}
turnOn(argv[1]);
int level = 1;
int i;
while(YES) {
turnLeft();
for(i=0; i<level; i++) {
putBeepers(level);
move();
}
turnAround();
goUntilWall();
turnLeft();
move();
if(!frontIsClear())
{
break;
}
level++;
}
draw();
turnOff();
return 0;
}
void usage(char *binary_name) {
printf("Usage: %s <path-to-world-file>\n", binary_name);
}
// ---
void turnAround() {
turnLeft();
turnLeft();
}
void goUntilWall() {
while(frontIsClear()) {
move();
}
}
void putBeepers(int count) {
int i;
for(i=0; i<count; i++) {
putBeeper();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment