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
53
54
55
56
//! Defines a `Generator` that uses an evolutionary strategy to create new `FractalField` candidates.
//!
//! This generator is a core component of a genetic or evolutionary algorithm. It produces
//! new fields by applying a suite of mutations to an existing field.
use crateFractalField;
use crateMutationSuite;
use crateGenerator;
/*
Note: The commented-out code below represents a potential future refactor
where the `EvolutionaryGenerator` could be made generic over a `MutationStrategy`.
This would allow for easily swapping different mutation algorithms.
pub struct EvolutionaryGenerator<S: MutationStrategy> {
pub strategy: S,
pub count: usize,
}
impl<S: MutationStrategy> Generator for EvolutionaryGenerator<S> {
fn generate(&self) -> Vec<FractalField> {
// Initial random generation or seed-based
vec![FractalField::one()]
}
fn mutate(&self, field: &FractalField) -> Vec<FractalField> {
(0..self.count)
.map(|_| self.strategy.mutate(field))
.collect()
}
}
*/
/// A generator that creates a population of `FractalField`s by mutating a parent field.