A new model reveals how behavioral flexibility enables animals to survive environmental changes.