Similar patterns of interaction, such as network motifs and feedback loops, are used in many natural collective processes, probably because they have evolved independently under similar pressures. Here I consider how three environmental constraints may shape the evolution of collective behavior: the patchiness of resources, the operating costs of maintaining the interaction network that produces collective behavior, and the threat of rupture of the network. The ants are a large and successful taxon that have evolved in very diverse environments. Examples from ants provide a starting point for examining more generally the fit between the particular pattern of interaction that regulates activity, and the environment in which it functions.