fn kill_target(&self, killer: &Exa<'a>) -> Option<Shared<Exa<'a>>> {
        let k = killer;
        let host_exas: Vec<Shared<Exa<'a>>> = self
            .exas
            .clone()
            .into_iter()
            .filter(|e| *e.borrow() != *k && *e.borrow().host == *k.host)
            .collect();

        if host_exas.len() == 0 {
            return None;
        }

        let other_killers: Vec<Shared<Exa<'a>>> = host_exas
            .clone()
            .into_iter()
            .filter(|e| e.borrow().will_kill_this_cycle())
            .collect();

        if other_killers.len() != 0 {
            let choice = &other_killers[fastrand::usize(..other_killers.len())];
            return Some(choice.clone());
        }

        let descendants: Vec<Shared<Exa<'a>>> = host_exas
            .clone()
            .into_iter()
            .filter(|e| e.borrow().descendant_of(killer))
            .collect();

        if descendants.len() != 0 {
            let choice = &descendants[fastrand::usize(..descendants.len())];
            return Some(choice.clone());
        }

        let ancestors: Vec<Shared<Exa<'a>>> = host_exas
            .clone()
            .into_iter()
            .filter(|e| e.borrow().ancestor_of(killer))
            .collect();

        if ancestors.len() != 0 {
            let choice = &ancestors[fastrand::usize(..ancestors.len())];
            return Some(choice.clone());
        }

        let choice = &host_exas[fastrand::usize(..host_exas.len())];
        Some(choice.clone())
    }
/// Kill targeting seems pretty complex, and I haven't been able to
/// fully reverse engineer it. We're going to try this for now and hope
/// we don't run into any programs that are actually relying on the
/// exact kill behavior in the retail game. Kill targets are prioritized
/// based on:
/// - whether they are also performing a KILL this turn
/// - whether they are in our EXA chain, and newer than us
/// - whether they are in our EXA chain, and older than us
/// - everyone else
/// We take the first group that has any members, and pick a random
/// as-of-yet unkilled member from it, then kill it.
Kill targeting seems pretty complex, and I haven't been able to
fully reverse engineer it. We're going to try this for now and hope
we don't run into any programs that are actually relying on the
exact kill behavior in the retail game. Kill targets are prioritized
based on:
whether they are also performing a KILL this turn
whether they are in our EXA chain, and newer than us
whether they are in our EXA chain, and older than us
everyone else
We take the first group that has any members, and pick a random
as-of-yet unkilled member from it, then kill it.
Kill targeting seems pretty complex and I haven ' t been able to fully reverse engineer it . We ' re going to try this for now and hope we don ' t run into any programs that are actually relying on the exact kill behavior in the retail game . Kill targets are prioritized based on : whether they are also performing a KILL this turn whether they are in our EXA chain and newer than us whether they are in our EXA chain and older than us everyone else We take the first group that has any members and pick a random as - of - yet unkilled member from it then kill it .
fn kill_target(&self, killer: &Exa<'a>) -> Option<Shared<Exa<'a>>> {
        let k = killer;
        let host_exas: Vec<Shared<Exa<'a>>> = self
            .exas
            .clone()
            .into_iter()
            .filter(|e| *e.borrow() != *k && *e.borrow().host == *k.host)
            .collect();
        if host_exas.len() == 0 {
            return None;
        }
        let other_killers: Vec<Shared<Exa<'a>>> = host_exas
            .clone()
            .into_iter()
            .filter(|e| e.borrow().will_kill_this_cycle())
            .collect();
        if other_killers.len() != 0 {
            let choice = &other_killers[fastrand::usize(..other_killers.len())];
            return Some(choice.clone());
        }
        let descendants: Vec<Shared<Exa<'a>>> = host_exas
            .clone()
            .into_iter()
            .filter(|e| e.borrow().descendant_of(killer))
            .collect();
        if descendants.len() != 0 {
            let choice = &descendants[fastrand::usize(..descendants.len())];
            return Some(choice.clone());
        }
        let ancestors: Vec<Shared<Exa<'a>>> = host_exas
            .clone()
            .into_iter()
            .filter(|e| e.borrow().ancestor_of(killer))
            .collect();
        if ancestors.len() != 0 {
            let choice = &ancestors[fastrand::usize(..ancestors.len())];
            return Some(choice.clone());
        }
        let choice = &host_exas[fastrand::usize(..host_exas.len())];
        Some(choice.clone())
    }
fn kill_target ( & self , killer : & Exa < ' a > ) -> Option < Shared < Exa < ' a > > > { let k = killer ; let host_exas : Vec < Shared < Exa < ' a > > > = self . exas . clone ( ) . into_iter ( ) . filter ( | e | * e . borrow ( ) != * k && * e . borrow ( ) . host == * k . host ) . collect ( ) ; if host_exas . len ( ) == 0 { return None ; } let other_killers : Vec < Shared < Exa < ' a > > > = host_exas . clone ( ) . into_iter ( ) . filter ( | e | e . borrow ( ) . will_kill_this_cycle ( ) ) . collect ( ) ; if other_killers . len ( ) != 0 { let choice = & other_killers [ fastrand :: usize ( .. other_killers . len ( ) ) ] ; return Some ( choice . clone ( ) ) ; } let descendants : Vec < Shared < Exa < ' a > > > = host_exas . clone ( ) . into_iter ( ) . filter ( | e | e . borrow ( ) . descendant_of ( killer ) ) . collect ( ) ; if descendants . len ( ) != 0 { let choice = & descendants [ fastrand :: usize ( .. descendants . len ( ) ) ] ; return Some ( choice . clone ( ) ) ; } let ancestors : Vec < Shared < Exa < ' a > > > = host_exas . clone ( ) . into_iter ( ) . filter ( | e | e . borrow ( ) . ancestor_of ( killer ) ) . collect ( ) ; if ancestors . len ( ) != 0 { let choice = & ancestors [ fastrand :: usize ( .. ancestors . len ( ) ) ] ; return Some ( choice . clone ( ) ) ; } let choice = & host_exas [ fastrand :: usize ( .. host_exas . len ( ) ) ] ; Some ( choice . clone ( ) ) }
Kill targeting seems pretty complex, and I haven't been able to
fully reverse engineer it.
Kill targeting seems pretty complex and I haven ' t been able to fully reverse engineer it .
&self
killer
&Exa<'a>
&self
killer
&Exa<'a>