[Avida-SVN] r2875 - in branches/hjg-dev/source: cpu main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Fri Oct 24 08:11:41 PDT 2008
Author: hjg
Date: 2008-10-24 11:11:40 -0400 (Fri, 24 Oct 2008)
New Revision: 2875
Modified:
branches/hjg-dev/source/cpu/cHardwareCPU.cc
branches/hjg-dev/source/main/cAvidaConfig.h
branches/hjg-dev/source/main/cStats.cc
Log:
added multiple methods for computing reputation.
Modified: branches/hjg-dev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.cc 2008-10-24 15:10:45 UTC (rev 2874)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.cc 2008-10-24 15:11:40 UTC (rev 2875)
@@ -6733,13 +6733,23 @@
// update reputation to include this donation.
// get the current reputation; increment by 1.
- if (m_world->GetConfig().AUTO_REPUTATION.Get()) {
+ if (m_world->GetConfig().AUTO_REPUTATION.Get() == 1) {
// set rep to 1, since the organism donated
- organism->SetReputation(1);
+// organism->SetReputation(1);
+ int my_rep = organism->GetReputation();
+ organism->SetReputation(my_rep +1);
// get neighbor reputation
int rep = neighbor->GetReputation();
// if the organism has not yet donated, put it into bad standing
if (rep == 0) neighbor->SetReputation(-1);
+ } else if (m_world->GetConfig().AUTO_REPUTATION.Get() == 2) {
+ // reputation is proportional to how much you have donated/received
+
+ int my_rep = organism->GetReputation();
+ organism->SetReputation(my_rep +1);
+ // get neighbor reputation
+ int rep = neighbor->GetReputation();
+ neighbor->SetReputation(rep-1);
}
Modified: branches/hjg-dev/source/main/cAvidaConfig.h
===================================================================
--- branches/hjg-dev/source/main/cAvidaConfig.h 2008-10-24 15:10:45 UTC (rev 2874)
+++ branches/hjg-dev/source/main/cAvidaConfig.h 2008-10-24 15:11:40 UTC (rev 2875)
@@ -558,7 +558,7 @@
CONFIG_ADD_CUSTOM_FORMAT(REPUTATION_GROUP, "Reputation Settings");
CONFIG_ADD_VAR(RAW_MATERIAL_AMOUNT, int, 100, "Number of raw materials an organism starts with");
- CONFIG_ADD_VAR(AUTO_REPUTATION, bool, 1, "Is an organism's reputation automatically computed based on its donations");
+ CONFIG_ADD_VAR(AUTO_REPUTATION, int, 1, "Is an organism's reputation automatically computed based on its donations");
CONFIG_ADD_VAR(OTHER_RAW_MAT_MULT, double, 1.00, "Number multiplied by the number of raw materials received from another organism to compute reward");
CONFIG_ADD_VAR(MY_RAW_MAT_MULT, double, 1.00, "Number multiplied by the number of your raw materials");
Modified: branches/hjg-dev/source/main/cStats.cc
===================================================================
--- branches/hjg-dev/source/main/cStats.cc 2008-10-24 15:10:45 UTC (rev 2874)
+++ branches/hjg-dev/source/main/cStats.cc 2008-10-24 15:11:40 UTC (rev 2875)
@@ -1725,12 +1725,16 @@
cDoubleSum reciprocations;
cDoubleSum donors;
cDoubleSum recip_prob_change;
+ // difference between how many an organism donated & how many it received
+ cDoubleSum disparity;
+ cOrganism* org;
int min_rep = 100;
int max_rep = 0;
int cur_rep;
int pop_size = 0;
int num_alt =0;
+ int num_coop = 0;
df.WriteComment("Avida organism reputation information -- average donations, min donations, max donations");
df.WriteTimeStamp();
@@ -1739,20 +1743,26 @@
for(int i=0; i<m_world->GetPopulation().GetSize(); ++i) {
cPopulationCell& cell = m_world->GetPopulation().GetCell(i);
+ org = cell.GetOrganism();
+
if(cell.IsOccupied()) {
// const tArray<int>& org_rx = cell.GetOrganism()->GetPhenotype().GetCurReactionCount();
- cur_rep = cell.GetOrganism()->GetReputation();
+ cur_rep = org->GetReputation();
if (cur_rep < min_rep) min_rep = cur_rep;
if (max_rep < cur_rep) max_rep = cur_rep;
reputations.Add(cur_rep);
- donations.Add(cell.GetOrganism()->GetNumberOfDonations());
- reciprocations.Add(cell.GetOrganism()->GetNumberOfReciprocations());
- donors.Add(cell.GetOrganism()->GetNumberOfDonors());
- recip_prob_change.Add(cell.GetOrganism()->GetChangeInRecipProb());
+ donations.Add(org->GetNumberOfDonations());
+ reciprocations.Add(org->GetNumberOfReciprocations());
+ donors.Add(org->GetNumberOfDonors());
+ recip_prob_change.Add(org->GetChangeInRecipProb());
pop_size++;
- if ((cell.GetOrganism()->GetNumberOfDonations() + cell.GetOrganism()->GetNumberOfReciprocations()) > 0) num_alt++;
+ disparity.Add(org->GetNumberOfDonations() - org->GetOtherRawMaterials());
+
+ if (org->GetNumberOfDonations() > 0) num_alt++;
+ if ((org->GetNumberOfDonations()) > 0 && (org->GetOtherRawMaterials() > 0)) num_coop++;
+
}
}
// float rep = reputations/pop_size;
@@ -1762,10 +1772,12 @@
// df.Write(max_rep, "Maximum reputation");
df.Write(donations.Average(), "Avg. donations [donation]");
// df.Write(reciprocations.Average(), "Avg. reciprocations [reciprocation]");
+ df.Write(disparity.Average(), "Disparity between donations and collections [disparity]");
df.Write(donors.Average(), "Avg. number of donor partners [partners]");
// df.Write(recip_prob_change.Average(), "Avg. change in reciprocation probability [recipprob]");
df.Write(num_alt, "Number of altruists [altruists]");
+ df.Write(num_coop, "Number of cooperators [cooperators]");
More information about the Avida-cvs
mailing list