Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn mutate(chromosome: &mut str) {
- let mut tmp_random = rand::random::<f32>();
- for mut i in chromosome.chars() {
- tmp_random = rand::random::<f32>();
- if tmp_random < MUTATE_RATE {
- println!("Mutating!");
- match i {
- '0' => i = '1',
- '1' => i = '0',
- _ => continue,
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement