- #include "franca.h"
- #include <math.h>
- // recursive maze exploration
- Robot Tracer(1); //c4back1.cpp
- Box message;
- Clock myclock;
- int howlong;
- void explore1()
- {
- int direction; // Direction she will
face
-
while(myclock.time()<howlong)
- { //
- do
- {
- direction=rand()%4;
-
Tracer.face(direction);
- Tracer.mark(7);
- } // repeat until the
direction
- // leads to free square.
- while (Tracer.seewall());
- // Once the square ahead is clear
...
- Tracer.mark(); // Mark it
green
- Tracer.step(); // Step
forward
- explore1(); // continue
- // This part will only be executed
after
- // exploration is done!
- Tracer.face(direction+2);
- Tracer.step();
- }
- message.say("coming back!");
- }
- void mainprog()
- {
- howlong=ask("How long do you want
it?");
- explore1();
- }