Fireflies’ dazzling light displays are courtship rituals: flying males announce their presence as suitable mates to the females on the ground. Their light signal is composed of a species-specific on/off fight sequence repeated periodically. However, thousands of fireflies flashing in a swarm can create immense visual clutter that hinders the detection of potential mates. A partial solution to this visual clutter problem is to flash according to sequences that are more distinct and detectable than those of other individuals. Here, we investigate how distinguishable flash sequences can co-evolve by developing a method for simulating sequences that minimize their mutual similarity with each other while minimizing their energetic cost and predation risk. This simple set of rules produces flash sequences that are remarkably similar to those of real fireflies. In particular, we observe an emergent periodicity in the resulting sequences, despite the lack of any periodicity requirements on the sequences. In addition, we demonstrate a method of reconstructing the evolutionary pressures acting on sets of firefly species. We do so by carrying out simulations that follow known phylogenetic relationships of extant species alongside their characteristic flash patterns.