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

Method DoDonate

avida-core/source/cpu/cHardwareCPU.cc:4868–4889  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4866}
4867
4868void cHardwareCPU::DoDonate(cAvidaContext& ctx, cOrganism* to_org)
4869{
4870 assert(to_org != NULL);
4871
4872 const double merit_given = m_world->GetConfig().MERIT_GIVEN.Get();
4873 const double merit_received = m_world->GetConfig().MERIT_RECEIVED.Get();
4874
4875 double cur_merit = m_organism->GetPhenotype().GetMerit().GetDouble();
4876 cur_merit -= merit_given;
4877 if (cur_merit < 0) cur_merit=0;
4878
4879 // Plug the current merit back into this organism and notify the scheduler.
4880 m_organism->UpdateMerit(ctx, cur_merit);
4881 m_organism->GetPhenotype().SetIsEnergyDonor();
4882
4883 // Update the merit of the organism being donated to...
4884 double other_merit = to_org->GetPhenotype().GetMerit().GetDouble();
4885 other_merit += merit_received;
4886 to_org->UpdateMerit(ctx, other_merit);
4887 to_org->GetPhenotype().SetIsEnergyReceiver();
4888
4889}
4890
4891void cHardwareCPU::DoEnergyDonate(cAvidaContext& ctx, cOrganism* to_org)
4892{

Callers

nothing calls this directly

Calls 7

GetConfigMethod · 0.80
SetIsEnergyDonorMethod · 0.80
SetIsEnergyReceiverMethod · 0.80
GetMethod · 0.45
GetDoubleMethod · 0.45
GetMeritMethod · 0.45
UpdateMeritMethod · 0.45

Tested by

no test coverage detected