Theory of Fitness in a Heterogeneous Environment. II. Developmental Flexibility and Niche Selection