\b;Exercice
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.

\b;Remark
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 :
\c;
\s;object   front, left, right;
\s;
\s;front = radar(Barrier,   0, 45, 0, 5);
\s;left  = radar(Barrier,  90, 45, 0, 5);
\s;right = radar(Barrier, -90, 45, 0, 5);
\s;
\s;if ( front == null )
\s;{
\s;	move(5);
\s;	return;
\s;}
\s;if ( left == null )
\s;{
\s;	turn(90);
\s;	move(5);
\s;	return;
\s;}
\s;if ( right == null )
\s;{
\s;	turn(-90);
\s;	move(5);
\s;	return;
\s;}
\n;
\b;Aide
Si vous avez besoin d'aide, consultez la documentation des instructions \c;\l;while\u cbot\while;\n;, \c;\l;radar\u cbot\radar;\n;, \c;\l;if\u cbot\if;\n;, \c;\l;move\u cbot\move;\n; et \c;\l;turn\u cbot\turn;\n;.

\t;Voir aussi
\l;Exercice précédent\u tlaby1; et \l;programmation\u cbot;.
