next_generation: Creating the next Population

Description Usage Arguments Details Value Examples

Description

next_generation is used to apply genetic recombination and mutation to the current population of strategies to create a new population.

Usage

1
next_generation(population, all_scores)

Arguments

population

a list containing an initial population made with create_population.

all_scores

a matrix containing all scores for each individual and each repetition made with life_cycle.

Details

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.

Value

a new population of the same size as the previous population.

Examples

1
2
3
first_population <- create_population(100)
scores <- life_cycle(first_population, c(5, 5), 9, 100, 200)
next_generation(first_population, scores)

Tabea123/FindMyCat documentation built on June 5, 2019, 7:56 a.m.