Those caterpillars best suited to the environment survived and passed on their genes. No coloured lolly sticks were hurt in the course of this experiment!