Documentation ¶
Overview ¶
Package simple provides a simple implementation of a population, where all agents are in a single species. Agents are selected and bred to create the next generation with the same number of agents.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Population ¶
type Population[T any] struct { Agents []*goevo.Agent[T] Selection goevo.SelectionStrategy[T] Reproduction goevo.ReproductionStrategy[T] }
Population has a single species, and generates the entire next generation by selcting and breeding from the previous one.
func NewPopulation ¶
func NewPopulation[T any](newGenotype func() T, n int, selection goevo.SelectionStrategy[T], reproduction goevo.ReproductionStrategy[T]) *Population[T]
NewPopulation creates a new SimplePopulation with n agents, each with a new genotype created by newGenotype.
func (*Population[T]) All ¶
func (p *Population[T]) All() []*goevo.Agent[T]
Agents returns the agents in the population.
TODO(change this to an iterator once they get added to the language, as this will increase performance in other cases)
func (*Population[T]) NextGeneration ¶
func (p *Population[T]) NextGeneration() goevo.Population[T]
NextGeneration creates a new SimplePopulation from the current one, using the given selection and reproduction strategies.