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

Method AddPredPreyAV

avida-core/source/main/cPopulationInterface.cc:1752–1767  ·  view source on GitHub ↗

Creates a new avatar based on the organism's forage target as a predator or prey, and adds it to the cell

Source from the content-addressed store, hash-verified

1750
1751// Creates a new avatar based on the organism's forage target as a predator or prey, and adds it to the cell
1752void cPopulationInterface::AddPredPreyAV(cAvidaContext& ctx, int av_cell_id)
1753{
1754 // Add predator (saved as input avatar)
1755 if (!GetOrganism()->IsPreyFT()) {
1756 sIO_avatar predAV(av_cell_id, 0, -1, true, false);
1757 m_avatars.Push(predAV);
1758 m_world->GetPopulation().GetCell(av_cell_id).AddPredAV(ctx, GetOrganism());
1759 // Add prey (saved as output avatar)
1760 } else {
1761 sIO_avatar preyAV(av_cell_id, 0, -1, false, true);
1762 m_avatars.Push(preyAV);
1763 m_world->GetPopulation().GetCell(av_cell_id).AddPreyAV(ctx, GetOrganism());
1764 }
1765 // Find the created avatar's faced cell
1766 SetAVFacedCellID(ctx, GetNumAV() - 1);
1767}
1768
1769// Switches the avatar from being a predator to a prey avatar or vice-versa
1770void cPopulationInterface::SwitchPredPrey(cAvidaContext& ctx, int av_num)

Callers 4

ActivateOffspringMethod · 0.45
LoadPopulationMethod · 0.45
InjectMethod · 0.45
InjectCloneMethod · 0.45

Calls 5

IsPreyFTMethod · 0.80
AddPredAVMethod · 0.80
AddPreyAVMethod · 0.80
PushMethod · 0.45
GetCellMethod · 0.45

Tested by

no test coverage detected