Skip to content

Commit

Permalink
create progress bar for basic example
Browse files Browse the repository at this point in the history
  • Loading branch information
HyperCodec committed May 15, 2024
1 parent 44b7fdb commit 6d17ec6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use neat::*;
use rand::prelude::*;
use indicatif::{ProgressBar, ProgressStyle};

#[derive(PartialEq, Clone, Debug, DivisionReproduction, RandomlyMutable)]
#[cfg_attr(feature = "crossover", derive(CrossoverReproduction))]
Expand Down Expand Up @@ -103,10 +104,19 @@ fn main() {
crossover_pruning_nextgen,
);

for _ in 0..100 {
const GENS: u64 = 1000;
let pb = ProgressBar::new(GENS)
.with_style(ProgressStyle::with_template("[{elapsed_precise}] {bar:40.cyan/blue} | {msg} {pos}/{len}")
.unwrap())
.with_message("gen");

for _ in 0..GENS {
sim.next_generation();
pb.inc(1);
}

pb.finish();

#[cfg(not(feature = "serde"))]
let mut fits: Vec<_> = sim.genomes.iter().map(fitness).collect();

Expand Down

0 comments on commit 6d17ec6

Please sign in to comment.