-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpecies.h
53 lines (39 loc) · 1.05 KB
/
Species.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Species.h
// I. Ahmed
//
// This declares the Species class, which represents a species
// in the NEAT algorithm.
#pragma once
#include <vector>
#include "Genome.h"
class Species
{
public:
// Genomes.
std::vector<Genome> genomes;
// ID.
int id = 0;
// Age.
int age = 0;
// Best fitness.
double best_fitness = 0;
// Best genome.
Genome best_genome;
// Stale age (how many generations in which the best fitness hasn't
// improved).
int stale_age = 0;
// Next genome ID.
int next_genome_id = 0;
// Default constructor.
Species() = default;
// Clones the seed genome and randomizes its weights.
Species(const Genome &seed_genome, int species_size);
// Sets the best fitness to the maximum of all genomes' fitnesses and
// updates the best genome correspondingly.
void set_best_fitness_and_genome();
// Sorts genomes by fitness (higher fitness is better) in descending
// order.
void sort_genomes();
// Adds a genome.
void add_genome(Genome &genome);
};