What are the evolutionary processes that have produced extraordinary cognitive diversity across the animal kingdom? New approaches, informed by evolutionary biology, neuroscience and psychology, are allowing us to elucidate how different aspects of cognition enhance survival and reproduction for species that live very different lives. Here, we will explore how natural selection customizes animal minds to maximise evolutionary success.