Selectivity is adjusted relative to environmental conditions by adjusting the expected quality of the environment a ie (Fig. 1 d, compare dark gray and black). When a forager’s stomach is not full at DIGESTIONTIME, the forager decreases its environmental expectation: a ie′=(1.0−ϕ i)a ie; otherwise the expectation is increased: a ie′=(1.0+ϕ i)a ie, where ϕ i determines the rate with which the expected quality of the environment a ie is changed. Each time the forager is too selective, it does not fill its stomach and reduces its selectivity, and vice versa. As a result, a ie is tuned in order to optimise energy intake, within the constraints of the algorithm. Qualitatively, this selection algorithm can give rise to the optimal food choice rule  where only resources above a certain perceived quality are eaten and all others are ignored (zero-one rule). Note however that our algorithm works on perceived quality and not actual quality since the foragers are learning about resource quality and are not omniscient. Moreover, we let selectivity parameter σ i evolve, so that while the zero-one rule is possible, it need not evolve and we don’t restrict the selection algorithm in this sense.