Collective behaviors of groups of animals, such as schooling and shoaling of fish, are central to species survival, but genes that regulate these activities are not known. Here we parsed collective behavior of groups of adult zebrafish using computer vision and unsupervised machine learning into a set of highly reproducible, unitary, several hundred millisecond states and transitions, which together can account for the entirety of relative positions and postures of groups of fish. Using CRISPR-Cas9 we then targeted for knockout 35 genes associated with autism and schizophrenia. We found mutations in three genes had distinctive effects on the amount of time spent in the specific states or transitions between states. Mutation in immp2l (inner mitochondrial membrane peptidase 2-like gene) enhances states of cohesion, so increases shoaling; mutation in in the Nav1.1 sodium channel, scn1lab+/− causes the fish to remain scattered without evident social interaction; and mutation in the adrenergic receptor, adra1aa−/−, keeps fish close together and retards transitions between states, leaving fish motionless for long periods. Motor and visual functions seemed relatively well-preserved. This work shows that the behaviors of fish engaged in collective activities are built from a set of stereotypical states. Single gene mutations can alter propensities to collective actions by changing the proportion of time spent in these states or the tendency to transition between states. This provides an approach to begin dissection of the molecular pathways used to generate and guide collective actions of groups of animals.