Click on the green flag and observe the behavior of the ant. Even though there is randomness in the code the ant tends to spend most of its time along an edge of the box. In biological terms, insects exhibit the same behavior when placed in a container and allowed to roam free. Also see: https://scratch.mit.edu/projects/36862440/ https://scratch.mit.edu/projects/10443264/
This project presents a simple example of the use of 'collision detection'. The antennae of the ant are tipped with a color and the collision test is 'if this color touches black' then…. The left-right motion of the ant is randomly generated. When the ant 'collides' with the black walls of the box it backs up and then moves forward until another collision takes place. If the ant has not collided with a wall it moves forward until it does. The digital ant exhibits what is called edge-following behavior.