# Simple haploid selection model simulator
# p0 = initial allele frequency for "A" allele/genotype
# w1 = fitness for "A" allele/genotype
# w2 = fitness for "a" allele/genotype
# n = number of generations to follow
# This is an example of a deterministic model. It is deterministic in
# that no matter how many times we run it, if we start with the same set
# of starting conditions (p0, w1, w2) we will get exactly the same
# result. In the "real world" we also need to account for population
# size (and fluctations) and how that can influence allele frequencies
# via drift, and random variation (due to the environment for instance).
haploid.selection 0.9999)) {
fixation 0.9999))
cat("fixation for A1 occurs approximately at generation:", fixation )
} else {
maxAlleleFreq