Crates.io | profqu_neat |
lib.rs | profqu_neat |
version | 0.1.1 |
source | src |
created_at | 2023-01-18 20:56:33.315264 |
updated_at | 2023-01-18 21:04:45.594185 |
description | A library that implements the NEAT algorithm |
homepage | |
repository | https://github.com/ProfessorQu/profqu_neat |
max_upload_size | |
id | 762051 |
size | 96,281 |
A crate that implements the NEAT algorithm Created according to a tutorial from Finn Eggers. I tried to implement NEAT from the official github repository, but I couldn't figure out how to do it, so I used Finn's implementation.
Then I looked on Youtube and found Finn Eggers and his tutorial really helped me with creating this library.
Doesn't allow recurrent connections in the networks.
use profqu_neat::Neat;
// Load config and create new Neat
Neat::load_config_from_file("src/config.txt");
let mut neat = Neat::new(10, 1, 1000);
// Create inputs
let input: Vec<f32> = vec![rand::random(); 10];
// Try to evolve the clients
for _iteration in 0..200 {
for mut client in neat.iter_clients() {
let fitness = client.calculate(&input)[0];
client.fitness = fitness;
}
neat.evolve();
}
/// Get the best client
let best = neat.best_client().expect("Failed to get client");
/// Print all the data
neat.print_species();
println!("Best: {best:?}");
assert!(best.fitness > 0.8);