@@ -22,14 +22,14 @@ struct MyGenome {
22
22
23
23
// required in all of the builtin functions as requirements of `DivsionReproduction` and `CrossoverReproduction`
24
24
impl RandomlyMutable for MyGenome {
25
- fn mutate (& mut self , rate : f32 , rng : & mut impl rand :: Rng ) {
25
+ fn mutate (& mut self , rate : f32 , rng : & mut impl Rng ) {
26
26
self . field1 += rng . gen :: <f32 >() * rate ;
27
27
}
28
28
}
29
29
30
30
// required for `division_pruning_nextgen`.
31
31
impl DivsionReproduction for MyGenome {
32
- fn divide (& self , rng : & mut impl rand :: Rng ) -> Self {
32
+ fn divide (& self , rng : & mut impl ng ) -> Self {
33
33
let mut child = self . clone ();
34
34
child . mutate (0.25 , rng ); // use a constant mutation rate when spawning children in pruning algorithms.
35
35
child
@@ -44,7 +44,7 @@ impl Prunable for MyGenome {
44
44
}
45
45
}
46
46
47
- // helper trait that allows us to use `Vec::gen_random` for the initial population.
47
+ // allows us to use `Vec::gen_random` for the initial population.
48
48
impl GenerateRandom for MyGenome {
49
49
fn gen_random (rng : & mut impl rand :: Rng ) -> Self {
50
50
Self { field1 : rng . gen () }
@@ -66,11 +66,11 @@ Once you have your reward function, you can create a `GeneticSim` object to mana
66
66
67
67
``` rust
68
68
fn main () {
69
- let mut rng = rand :: thread_rng ();
69
+ let mut rng = rand :: rng ();
70
70
let mut sim = GeneticSim :: new (
71
71
// you must provide a random starting population.
72
72
// size will be preserved in builtin nextgen fns, but it is not required to keep a constant size if you were to build your own nextgen function.
73
- // in this case, you do not need to specify a type for `Vec::gen_random` because of the input of `my_fitness_fn`.
73
+ // in this case, the compiler can infer the type of `Vec::gen_random` because of the input of `my_fitness_fn`.
74
74
Vec :: gen_random (& mut rng , 100 ),
75
75
my_fitness_fn ,
76
76
division_pruning_nextgen ,
0 commit comments