class YAGA::Population(T, V)

Defined in:

yaga/population.cr

Constant Summary

MUTATION_PERCENT = 10_u8
PERCENT_RANGE = 1_u8..100_u8
SELECTION_BOTS = 8_u32
SIMULATIONS_HISTORY = 400_u64
TOTAL_BOTS = 64_u32

Constructors

Instance Method Summary

Constructor Detail

def self.new(total_bots : UInt32 = TOTAL_BOTS, selection_bots : UInt32 = SELECTION_BOTS, mutation_percent : UInt8 = MUTATION_PERCENT, crossover_enabled : Bool = true, random : Random = Random::DEFAULT, &) #

[View source]
def self.new(total_bots : UInt32 = TOTAL_BOTS, selection_bots : UInt32 = SELECTION_BOTS, mutation_percent : UInt8 = MUTATION_PERCENT, crossover_enabled : Bool = true, random : Random = Random::DEFAULT) #

[View source]

Instance Method Detail

def after_evolution(&block : UInt64 -> Void) : Void #

[View source]
def after_simulation(&block : UInt64, Bool -> Void) : Void #

[View source]
def after_training(&block : UInt64, V, UInt64 -> Void) : Void #

[View source]
def before_evolution(&block : UInt64 -> Void) : Void #

[View source]
def before_simulation(&block : UInt64, Bool -> Void) : Void #

[View source]
def before_training(&block : UInt64, V, UInt64 -> Void) : Void #

[View source]
def bots #

[View source]
def crossover : Void #

Crossover specific amount of bots with best selection


[View source]
def evolve!(native : Bool = false) : Void #

Usually it is not needed to call this method explicitly But there are no restrictions about that Do not use argument native, it is only for internal usage Or selection will not be collected


[View source]
def finalize_evolution : Void #

Reset lask part of bots to prevent stagnation


[View source]
def fitness_history #

[View source]
def generation #

[View source]
def generation=(generation : UInt64) #

[View source]
def mutate : Void #

Mutate specific amount of bots out of selection


[View source]
def selection #

[View source]
def selection_bots #

[View source]
def simulate_each(&block : Bot(T, V), UInt64 -> Void) : Void #

[View source]
def simulate_world(&block : Array(Bot(T, V)), UInt64 -> Void) : Void #

[View source]
def total_bots #

[View source]
def train_each(goal : V, generation_cap : UInt64 = 10000_u64, &block : Bot(T, V), UInt64 -> V) : UInt64 #

[View source]
def train_world(goal : V, generation_cap : UInt64 = 10000_u64, &block : Array(Bot(T, V)), UInt64 -> Void) : UInt64 #

[View source]