Le programme écrit dans l'\l;exercice précédent\u tlaby1; doit fonctionner quel que soit la disposition du labyrinthe. Pour vérifier cela, exécutez le même programme. Le \l;robot\u object\bottr; devrait se déplacer correctement dans ce nouveau labyrinthe qu'il ne connait pas.
The labyrinth is not exactly the same, but this should be of no importance, as the program adapts to what it "sees".
\image tlaby1 10 10;
\b;General principle
Use an infinite \c;\l;while\u cbot\while;\n; loop in order to execute the previous program several times:
\s;\c;while ( true )
\s;{
\s; \n;If there is nothing in front, move forward\c;
\s; \n;If there is nothing on your left hand, turn left\c;
\s; \n;If there is nothing on your right hand, turn right\c;
\s;}
\n;
Inside this \c;while\n; loop, replace the \c;return\n; instructions by \c;\l;continue\u cbot\continue;\n; instructions. \c;return\n; would quit the program, which is not what we want here. \c;continue\n; will just resume the execution at the beginning of the \c;\l;while\u cbot\while;\n; loop:
\s;\c;if ( front == null )
\s;{
\s; move(5);
\s; continue;
\s;}
\n;
\b;Remember
Here is again the program of the previous exercise :