pub struct MutationEngine {
pub mutation_rate: f64,
}Expand description
Controlled randomness for creative exploration of ternary patterns.
Mutates patterns by flipping, rotating, inserting, or deleting values based on a mutation rate.
Fields§
§mutation_rate: f64Probability of each element being mutated (0.0 to 1.0).
Implementations§
Source§impl MutationEngine
impl MutationEngine
pub fn new(mutation_rate: f64) -> Self
Sourcepub fn flip_mutate(&self, pattern: &Pattern, seed: usize) -> Pattern
pub fn flip_mutate(&self, pattern: &Pattern, seed: usize) -> Pattern
Deterministic flip: negate values at indices determined by seed.
Sourcepub fn rotate(&self, pattern: &Pattern, shift: usize) -> Pattern
pub fn rotate(&self, pattern: &Pattern, shift: usize) -> Pattern
Rotate pattern by shift positions.
Sourcepub fn insert_mutate(
&self,
pattern: &Pattern,
value: Ternary,
seed: usize,
) -> Pattern
pub fn insert_mutate( &self, pattern: &Pattern, value: Ternary, seed: usize, ) -> Pattern
Insert a value at a position determined by seed.
Sourcepub fn delete_mutate(&self, pattern: &Pattern, seed: usize) -> Pattern
pub fn delete_mutate(&self, pattern: &Pattern, seed: usize) -> Pattern
Remove a value at a position determined by seed.
Trait Implementations§
Source§impl Clone for MutationEngine
impl Clone for MutationEngine
Source§fn clone(&self) -> MutationEngine
fn clone(&self) -> MutationEngine
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for MutationEngine
impl RefUnwindSafe for MutationEngine
impl Send for MutationEngine
impl Sync for MutationEngine
impl Unpin for MutationEngine
impl UnsafeUnpin for MutationEngine
impl UnwindSafe for MutationEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more