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

Method GetConfusionOddsDensity

avida-core/source/main/cOrgSensor.cc:1296–1323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1294}
1295
1296void cOrgSensor::GetConfusionOddsDensity(cAvidaContext& ctx, double& odds, cOrganism* first_org)
1297{
1298 int prey_count = 0;
1299 Apto::Array<int> neighborhood;
1300 if (!m_use_avatar) {
1301 if (first_org->IsPreyFT()) {
1302 prey_count++;
1303 first_org->GetOrgInterface().GetNeighborhoodCellIDs(neighborhood);
1304 for (int j = 0; j < neighborhood.GetSize(); j++) {
1305 if (first_org->GetOrgInterface().GetCell(neighborhood[j])->IsOccupied() &&
1306 !first_org->GetOrgInterface().GetCell(neighborhood[j])->GetOrganism()->IsDead()) {
1307 if (first_org->GetOrgInterface().GetCell(neighborhood[j])->GetOrganism()->IsPreyFT()) prey_count++;
1308 }
1309 }
1310 }
1311 }
1312 else {
1313 prey_count += first_org->GetOrgInterface().GetCell(first_org->GetOrgInterface().GetAVCellID())->GetNumPreyAV(); // self cell
1314 first_org->GetOrgInterface().GetAVNeighborhoodCellIDs(neighborhood);
1315 for (int j = 0; j < neighborhood.GetSize(); j++) {
1316 prey_count += first_org->GetOrgInterface().GetCell(neighborhood[j])->GetNumPreyAV();
1317 }
1318 }
1319
1320 // first org is alone and doesn't count:
1321 prey_count--;
1322 odds = 1.0 - (0.10 * (double) prey_count); // 0 friend = 0% confusion, 1 friend = 10%, 10 friends = 100%
1323}
1324
1325void cOrgSensor::GetConfusionOddsFacings(cAvidaContext& ctx, double& odds, cOrganism* first_org)
1326{

Callers

nothing calls this directly

Calls 10

IsPreyFTMethod · 0.80
IsOccupiedMethod · 0.80
GetNumPreyAVMethod · 0.80
GetSizeMethod · 0.45
GetCellMethod · 0.45
IsDeadMethod · 0.45
GetOrganismMethod · 0.45
GetAVCellIDMethod · 0.45

Tested by

no test coverage detected