ScratchData LogoScratchData
Back to popswilson's profile

Ant In a Box

POpopswilson•Created April 3, 2016
Ant In a Box
10
4
95 views
View on Scratch

Instructions

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/

Description

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.

Project Details

Project ID103933276
CreatedApril 3, 2016
Last ModifiedApril 6, 2019
SharedApril 4, 2016
Visibilityvisible
CommentsAllowed