The 'ants' have only a few simple behaviours:
- Wander randomly
- If an ant encounters a grain, and isn't carrying a grain, it picks up the grain
- If an ant encounters a grain, and is carrying a grain, it drops its grain and backs away. While it's backing away, it can't pick up any grains.
Using just this, the ants are able to organise the randomly dropped grains into piles.