Description Usage Arguments Details Value Examples
next_generation
is used to apply genetic recombination and mutation
to the current population of strategies to create a new population.
1 | next_generation(population, all_scores)
|
population |
a list containing an initial population made with
|
all_scores |
a matrix containing all scores for each individual and each
repetition made with |
Evolution works in the following way: The strategies with the two highest scores are chosen as the parent individuals. The two parents are mated to create offspring. A position at which to split the two parent stategies is randomly chosen. The offspring receives the genetic material from parent A before that position and from parent B after that position. Note: This is not done vice versa; otherwise the same situation can possibly exist twice in one strategy table.
With a small probability, 1 to 5 mutations occur in a random row of the strategy table. A mutation replaces the move that is inherited by the parent with a random movement.
The function creates as much offspring as there were individuals in the previous population to fill up the new population.
a new population of the same size as the previous population.
1 2 3 | first_population <- create_population(100)
scores <- life_cycle(first_population, c(5, 5), 9, 100, 200)
next_generation(first_population, scores)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.