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(); }
void run() { /* BEGIN SOLUTION */ // Make sure we have a wall to the left left(); while (!isFacingWall()) forward(1); right(); while (!isOverBaggle()) stepHandOnWall(); pickupBaggle(); }