Labyrinth

[color=#999999][color=#999999]This activity belongs to the [i]GeoGebra book[/i] [url=https://www.geogebra.org/m/dm9prd7h]Attractive projects.[/url][/color][/color][b][br][br]2D project[/b]: [i]create robots that adapt to the environment.[/i][br][br]In this last example, the [b]robot (green point) does not have any information about the shape of the labyrinth[/b]. It only detects if there is free space to its right (in which case it turns to the right to stick to the right wall) or if there is an obstacle in front (in which case it turns to the left).[br][br]This simple rule is enough to not detach from its right wall and get out of the labyrinth (although not in the shortest possible way). To do this, two instructions are enough in the script of the robot:[br][br][list][*]SetValue(v, If(dPD> 8, vn, If(dPA <2, -vn, v)))[/*][*]SetValue(P, P + v)[/*][/list]A second robot (yellow point) does the same changing the right for the left. Between the two, they go through the entire labyrinth, but the green point goes less path to get to the exit.[br][br]Note that the walls of the labyrinth actually make up two polygons with many sides, separated by a path. The green point circles one of the polygons in a clockwise direction, while the yellow point circles the other polygon in a counterclockwise direction. Both travel (in opposite directions) the path that separates both polygons (bicolor trace), which is the shortest route to go from the entrance to the exit of the labyrinth.
[color=#999999]Author of the construction of GeoGebra: [color=#999999][url=https://www.geogebra.org/u/rafael]Rafael Losada[/url][/color][/color]

Information: Labyrinth