MCPcopy Create free account
hub / github.com/devosoft/avida / GetPredGroupAttackNeighbors

Method GetPredGroupAttackNeighbors

avida-core/source/cpu/cHardwareExperimental.cc:7212–7240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7210}
7211
7212Apto::Array<cOrganism*> cHardwareExperimental::GetPredGroupAttackNeighbors()
7213{
7214 Apto::Array<int> neighborhood;
7215 Apto::Array<cOrganism*> pack;
7216 pack.Push(m_organism);
7217 if (!m_use_avatar) {
7218 m_organism->GetOrgInterface().GetNeighborhoodCellIDs(neighborhood);
7219 for (int j = 0; j < neighborhood.GetSize(); j++) {
7220 if (m_organism->GetOrgInterface().GetCell(neighborhood[j])->IsOccupied() &&
7221 !m_organism->GetOrgInterface().GetCell(neighborhood[j])->GetOrganism()->IsDead()) {
7222 if (!m_organism->GetOrgInterface().GetCell(neighborhood[j])->GetOrganism()->IsPreyFT()) {
7223 pack.Push(m_organism->GetOrgInterface().GetCell(neighborhood[j])->GetOrganism());
7224 }
7225 }
7226 }
7227 }
7228 else {
7229 m_organism->GetOrgInterface().GetAVNeighborhoodCellIDs(neighborhood);
7230 for (int j = 0; j < neighborhood.GetSize(); j++) {
7231 if (m_organism->GetOrgInterface().GetCell(neighborhood[j])->HasPredAV()) {
7232 Apto::Array<cOrganism*> predators = m_organism->GetOrgInterface().GetCell(neighborhood[j])->GetCellInputAVs();
7233 for (int i = 0; i < predators.GetSize(); i++) {
7234 if (!predators[i]->IsDead() && !predators[i]->IsPreyFT()) pack.Push(predators[i]);
7235 }
7236 }
7237 }
7238 }
7239 return pack;
7240}
7241
7242Apto::Array<cOrganism*> cHardwareExperimental::GetPredSameGroupAttackNeighbors()
7243{

Callers

nothing calls this directly

Calls 11

IsOccupiedMethod · 0.80
IsPreyFTMethod · 0.80
HasPredAVMethod · 0.80
GetCellInputAVsMethod · 0.80
PushMethod · 0.45
GetSizeMethod · 0.45
GetCellMethod · 0.45
IsDeadMethod · 0.45
GetOrganismMethod · 0.45

Tested by

no test coverage detected