evolution: Evolution of the Best Strategy

Description Usage Arguments Details Value Examples

Description

evolution is used to evolve the best strategy table.

Usage

1
2
evolution(population_size, grid_size, n_evidence, steps, sessions,
generations)

Arguments

population_size

a number indicating the amount of individuals in each population.

grid_size

a numeric vector of the form c(nrows, ncolumns) which gives the size of the grid in x and y direction.

n_evidence

a number specifing the amount of evidence in the grid.

steps

a number indicating how many moves the robot should walk in one grid configuration.

sessions

a number indicating how many times the grid configuration is changed in one life cycle.

generations

a number indicating how many populations should be evolved.

Details

evolution calls all subordinate functions. First, the initial population of random strategies is generated with create_population. The fitness of each individual strategy is calculated with the function life_cycle. Fitness is determined by seeing how well a strategy lets the robot do on X different sessions. The number of sessions is determined by the user. One session consists of putting the robot at his starting position on a grid and then letting the robot move for X steps. The score of the strategy in each session is the number of bonus- and minuspoints the robot accumulates. The strategy’s fitness is its average score over the different sessions, each of which has a different grid configuration. A grid is generated with the arguments grid_size and n_evidence. The position of the evidence is randomly chosen.

With the function next_generation evolution is applied to the current population to create a new population of strategies. The two individuals from the current population with the highest scores are chosen as the parents of the new generation. The two parents are mated to create offspring. At a randomly chosen position the parental strategies are split. Offpring is created by recombining the pieces of parental material. With a small probability, mutations accur. Offspring is generated until the next population has the same amount of individuals as the first generation.

This procedure is repeated for as many generations as the user indicates. evolution returns the best strategy table.

Value

the individual with the highest score.

Examples

1
evolution(100, c(10, 10), 11, 100, 50, 1000)

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