fn calc_fitness(mut self, target: &Vec<i32>) -> Self {
    // closer to the target number is better
    let r_fitness = 1.0 - ((self.genes[0] - target[0]).abs() as f32) / 255.0;
    let g_fitness = 1.0 - ((self.genes[1] - target[1]).abs() as f32) / 255.0;
    let b_fitness = 1.0 - ((self.genes[2] - target[2]).abs() as f32) / 255.0;

    let fitness = (r_fitness + b_fitness + g_fitness) / 3.0;

    self.fitness = fitness;
    self
  }
// this uses an exponential fit that is MUCH MUCH MUCH faster at finding a "solution".
this uses an exponential fit that is MUCH MUCH MUCH faster at finding a "solution".
this uses an exponential fit that is MUCH MUCH MUCH faster at finding a " solution " .
fn calc_fitness(mut self, target: &Vec<i32>) -> Self {
    // closer to the target number is better
    let r_fitness = 1.0 - ((self.genes[0] - target[0]).abs() as f32) / 255.0;
    let g_fitness = 1.0 - ((self.genes[1] - target[1]).abs() as f32) / 255.0;
    let b_fitness = 1.0 - ((self.genes[2] - target[2]).abs() as f32) / 255.0;
    let fitness = (r_fitness + b_fitness + g_fitness) / 3.0;
    self.fitness = fitness;
    self
  }
fn calc_fitness ( mut self , target : & Vec < i32 > ) -> Self { // closer to the target number is better let r_fitness = 1.0 - ( ( self . genes [ 0 ] - target [ 0 ] ) . abs ( ) as f32 ) / 255.0 ; let g_fitness = 1.0 - ( ( self . genes [ 1 ] - target [ 1 ] ) . abs ( ) as f32 ) / 255.0 ; let b_fitness = 1.0 - ( ( self . genes [ 2 ] - target [ 2 ] ) . abs ( ) as f32 ) / 255.0 ; let fitness = ( r_fitness + b_fitness + g_fitness ) / 3.0 ; self . fitness = fitness ; self }
this uses an exponential fit that is MUCH MUCH MUCH faster at finding a "solution".
this uses an exponential fit that is MUCH MUCH MUCH faster at finding a " solution " .
mut self
target
&Vec<i32>