// Lurk around, if there's an enemy in secondary range, secondary fire, else if primary range primary fire + move once
Lurk around, if there's an enemy in secondary range, secondary fire, else if primary range primary fire + move once
Lurk around if there ' s an enemy in secondary range secondary fire else if primary range primary fire + move once
fn phase_1(mech: &impl MechInstruments) -> Vec<MechCommand> {
     let last_scan = mech.last_radar_scan().unwrap_or(vec![]);
     let within_secondary = last_scan.iter().filter(|e| enemy_within_range(mech.secondary_range(), &mech.position(), &e.location)).collect::<Vec<_>>();
     let within_primary = within_secondary.iter().filter(|e| enemy_within_range(mech.primary_range(),  &mech.position(), &e.location)).map(|e| *e).collect::<Vec<_>>();
     if let Some(enemy) = find_enemy(within_secondary) {
          vec![
               mech.fire_secondary(mech.direction_to(&enemy.location))
          ]
     } else if let Some(enemy) = find_enemy( within_primary) {
          vec![
               mech.fire_primary(mech.direction_to(&enemy.location)),
               mech.request_radar()
          ]
     } else {
          let mut move_mech = evasive_maneuvers(mech, mech.world_size());
          move_mech.append(&mut vec![mech.request_radar()]);
          move_mech
     }
}
fn phase_1 ( mech : & impl MechInstruments ) -> Vec < MechCommand > { let last_scan = mech . last_radar_scan ( ) . unwrap_or ( vec ! [ ] ) ; let within_secondary = last_scan . iter ( ) . filter ( | e | enemy_within_range ( mech . secondary_range ( ) , & mech . position ( ) , & e . location ) ) . collect :: < Vec < _ > > ( ) ; let within_primary = within_secondary . iter ( ) . filter ( | e | enemy_within_range ( mech . primary_range ( ) , & mech . position ( ) , & e . location ) ) . map ( | e | * e ) . collect :: < Vec < _ > > ( ) ; if let Some ( enemy ) = find_enemy ( within_secondary ) { vec ! [ mech fire_secondary ( mech direction_to ( enemy location ) ) ] } else if let Some ( enemy ) = find_enemy ( within_primary ) { vec ! [ mech fire_primary ( mech direction_to ( enemy location ) ) mech request_radar ( ) ] } else { let mut move_mech = evasive_maneuvers ( mech , mech . world_size ( ) ) ; move_mech . append ( & mut vec ! [ mech request_radar ( ) ] ) ; move_mech } }
Lurk around, if there's an enemy in secondary range, secondary fire, else if primary range primary fire + move once
Lurk around if there ' s an enemy in secondary range secondary fire else if primary range primary fire + move once
mech
&impl MechInstruments