Convenience function that combines parent selection, replication, and mutation.

evolve_generation(
  molecules,
  n_molecules = length(molecules),
  alphabet = c("A", "U", "G", "C"),
  mutation_rate = 0.01,
  selection_strength = 1
)

Arguments

molecules

Character vector of symbolic molecular sequences.

n_molecules

Number of molecules in the next generation.

alphabet

Character vector used to build molecular sequences.

mutation_rate

Probability that a copied character mutates.

selection_strength

Strength of fitness-based selection. Use 0 for neutral drift.

Value

A character vector of next-generation molecules.

Examples

evolve_generation(c("AUGC", "UUUU"), n_molecules = 10)
#>  [1] "UUUU" "UUUU" "UUUU" "AUGC" "AUGC" "UUUU" "AUGC" "UUUU" "UUUU" "AUGC"