In order to account for possible trade offs due to resource shortages we can implement a sigmoid growth function. In this case a Gompertz growth equation parameterized as:
\[ f(x)=ae^{be^{cx}} \] where x the average resource level an individual had access to over a fixed time window into the past. a is the maximum fecundity possible (asymtote), and b and c control the shape of the curve
This implements a trade-off where a sequence of good environments will allow maximum offsrping production, but a more variable environment might cause an individual to scale back reproduction. I've plotted two different genotypes, one with a maximum fecundity of 23 (black line) and one of 17 (red line). This illustrates that the genes for fecundity provide a fitness advantage at almost every resource level.