Animal flocks, schools, and swarms perform extraordinary feats of collective behavior. How do they do it, and how does it help them?