The striking patterns of collective animal behavior, including ant trails, bird flocks, and fish schools, can result from local interactions among animals without centralized control. Several of these rules of interaction have been proposed, but it has proven difficult to discriminate which ones are implemented in nature. As a method to better discriminate among interaction rules, we propose to follow the slow birth of a rule of interaction during animal development. Specifically, we followed the development of zebrafish, Danio rerio, and found that larvae turn toward each other from 7 days postfertilization and increase the intensity of interactions until 3 weeks. This developmental dataset allows testing the parameter-free predictions of a simple rule in which animals attract each other part of the time, with attraction defined as turning toward another animal chosen at random. This rule makes each individual likely move to a high density of conspecifics, and moving groups naturally emerge. Development of attraction strength corresponds to an increase in the time spent in attraction behavior. Adults were found to follow the same attraction rule, suggesting a potential significance for adults of other species.