Given the description of the inner loop that constructs generation from generation the definition of the simulator is straightforward:
build_next_generation
until the
next generation has no surviving offspring
build_next_generation
was called).
Since the simulation is stochastic and depends so heavily on random number generators to determine the number of new mutations for each individual and whether or not an individual survives, to get an accurate measurement of the number of generations to extinction for any given combination of input parameters we need to compute the mean over several independent populations. Thus another input parameter to the simulator would be the number of populations to simulate, and an outer loop would call the simulator this number of times. In addition to printing the number of generations to extinction for each population, the simulator would now print the mean time to extinction over all populations, plus the standard deviation.