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

Method testAttack

avida-core/source/cpu/cHardwareBCR.cc:3857–3875  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3855}
3856
3857bool cHardwareBCR::testAttack(cAvidaContext& ctx)
3858{
3859 if (m_use_avatar && m_use_avatar != 2) return false;
3860
3861 if (m_world->GetConfig().PRED_PREY_SWITCH.Get() < 0) return false;
3862
3863 if (!m_use_avatar && !m_organism->IsNeighborCellOccupied()) return false;
3864 else if (m_use_avatar == 2 && !m_organism->GetOrgInterface().FacedHasPreyAV()) return false;
3865
3866 // prevent killing on refuges
3867 const cResourceLib& resource_lib = m_world->GetEnvironment().GetResourceLib();
3868 for (int i = 0; i < resource_lib.GetSize(); i++) {
3869 if (resource_lib.GetResource(i)->GetRefuge()) {
3870 if (!m_use_avatar && m_organism->GetOrgInterface().GetFacedResourceVal(ctx, i) >= resource_lib.GetResource(i)->GetThreshold()) return false;
3871 else if (m_use_avatar == 2 && m_organism->GetOrgInterface().GetAVFacedResourceVal(ctx, i) >= resource_lib.GetResource(i)->GetThreshold()) return false;
3872 }
3873 }
3874 return true;
3875}
3876
3877bool cHardwareBCR::testAttackChance(cAvidaContext& ctx, cOrganism* target, sAttackReg& reg, double odds)
3878{

Callers

nothing calls this directly

Calls 10

GetConfigMethod · 0.80
GetRefugeMethod · 0.80
GetThresholdMethod · 0.80
GetMethod · 0.45
FacedHasPreyAVMethod · 0.45
GetSizeMethod · 0.45
GetResourceMethod · 0.45
GetFacedResourceValMethod · 0.45
GetAVFacedResourceValMethod · 0.45

Tested by

no test coverage detected