void run() { /* BEGIN SOLUTION */ int state = 0 ; angleSum = 0; setDirection(chosenDirection); while ( !isOverBaggle() ){ switch ( state ){ case 0: // North runner mode while ( !isFacingWall() ) forward(1); right(); // make sure that we have a left wall angleSum--; state = 1; // time to enter the Left Follower mode break; case 1: // Left Follower Mode stepHandOnWall(); // follow the left wall if ( isChosenDirectionFree() && angleSum == 0 ) state =0; // time to enter in North Runner mode break; } } pickupBaggle(); }
/* BEGIN TEMPLATE */ void hunt(Color c) { /* BEGIN SOLUTION */ while (! isOverBaggle()) { if (isFacingTrail(c)) { brushDown(); forward(1); brushUp(); } else { left(); } } pickupBaggle(); }
/* BEGIN SOLUTION */ void goAndGet() { int i = 0; while (!isOverBaggle()) { i++; forward(1); } pickupBaggle(); while (i>0) { backward(1); i--; } dropBaggle(); }
void run() { /* BEGIN SOLUTION */ // Make sure we have a wall to the left left(); while (!isFacingWall()) forward(1); right(); while (!isOverBaggle()) stepHandOnWall(); pickupBaggle(); }
/* BEGIN TEMPLATE */ void run() { /* BEGIN SOLUTION */ evaluatePaths(); // write on each case the distance to the maze exit followShortestPath(); // make the buggle follow the shortest path pickupBaggle(); // enjoy the baggle! }