[Avida-SVN] r2827 - in branches/hjg-dev/source: actions main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Thu Oct 9 18:21:22 PDT 2008
Author: hjg
Date: 2008-10-09 21:21:22 -0400 (Thu, 09 Oct 2008)
New Revision: 2827
Modified:
branches/hjg-dev/source/actions/PrintActions.cc
branches/hjg-dev/source/main/cOrganism.h
branches/hjg-dev/source/main/cStats.cc
branches/hjg-dev/source/main/cStats.h
Log:
added stats for tracking the average, min, and max reputation.
Modified: branches/hjg-dev/source/actions/PrintActions.cc
===================================================================
--- branches/hjg-dev/source/actions/PrintActions.cc 2008-10-09 21:47:17 UTC (rev 2826)
+++ branches/hjg-dev/source/actions/PrintActions.cc 2008-10-10 01:21:22 UTC (rev 2827)
@@ -112,7 +112,11 @@
STATS_OUT_FILE(PrintCellVisitsData, visits.dat );
STATS_OUT_FILE(PrintFlowRateTuples, flow_rate_tuples.dat);
+// reputation
+STATS_OUT_FILE(PrintReputationData, reputation.dat);
+
+
#define POP_OUT_FILE(METHOD, DEFAULT) /* 1 */ \
class cAction ## METHOD : public cAction { /* 2 */ \
private: /* 3 */ \
@@ -2744,6 +2748,11 @@
action_lib->Register<cActionPrintGenomicSiteEntropy>("PrintGenomicSiteEntropy");
+ // Reputation
+ action_lib->Register<cActionPrintReputationData>("PrintReputationData");
+
+
+
// Grid Information Dumps
action_lib->Register<cActionDumpMemory>("DumpMemory");
action_lib->Register<cActionDumpFitnessGrid>("DumpFitnessGrid");
Modified: branches/hjg-dev/source/main/cOrganism.h
===================================================================
--- branches/hjg-dev/source/main/cOrganism.h 2008-10-09 21:47:17 UTC (rev 2826)
+++ branches/hjg-dev/source/main/cOrganism.h 2008-10-10 01:21:22 UTC (rev 2827)
@@ -451,10 +451,9 @@
int GetSelfRawMaterials() { return m_self_raw_materials; }
// retrieve the amount of raw materials collected from others
int GetOtherRawMaterials() { return m_other_raw_materials; }
- // Rotate the organism to face a specific neighboring organism.
- // This functionality is used to turn the donation recipient to the donor.
- //void RotateToFaceOrganism(cOrganism& org);
-
+ // get the number of donations
+ int GetReputation() { return (100 - m_self_raw_materials); }
+
protected:
// Initialize reputation support
// inline void InitReputation() {if (!m_self_raw_materials) {m_self_raw_materials = 100; m_other_raw_materials =0; }}
Modified: branches/hjg-dev/source/main/cStats.cc
===================================================================
--- branches/hjg-dev/source/main/cStats.cc 2008-10-09 21:47:17 UTC (rev 2826)
+++ branches/hjg-dev/source/main/cStats.cc 2008-10-10 01:21:22 UTC (rev 2827)
@@ -1715,3 +1715,40 @@
m_deme_fitness.clear();
}
+
+/* Print information about the reputation... */
+void cStats::PrintReputationData(const cString& filename){
+ cDataFile& df = m_world->GetDataFile(filename);
+
+ int reputations = 0;
+ int min_rep = 100;
+ int max_rep = 0;
+ int cur_rep;
+ int pop_size = 0;
+
+ df.WriteComment("Avida organism reputation information -- average donations, min donations, max donations");
+ df.WriteTimeStamp();
+ df.Write(m_update, "Update");
+
+
+ for(int i=0; i<m_world->GetPopulation().GetSize(); ++i) {
+ cPopulationCell& cell = m_world->GetPopulation().GetCell(i);
+ if(cell.IsOccupied()) {
+// const tArray<int>& org_rx = cell.GetOrganism()->GetPhenotype().GetCurReactionCount();
+ cur_rep = cell.GetOrganism()->GetReputation();
+
+ if (cur_rep < min_rep) min_rep = cur_rep;
+ if (max_rep < cur_rep) max_rep = cur_rep;
+ reputations += cur_rep;
+ pop_size++;
+ }
+ }
+ float rep = reputations/pop_size;
+ df.Write(rep, "Avg. reputation");
+ df.Write(min_rep, "Minimum reputation");
+ df.Write(max_rep, "Maximum reputation");
+
+
+ df.Endl();
+}
+
Modified: branches/hjg-dev/source/main/cStats.h
===================================================================
--- branches/hjg-dev/source/main/cStats.h 2008-10-09 21:47:17 UTC (rev 2826)
+++ branches/hjg-dev/source/main/cStats.h 2008-10-10 01:21:22 UTC (rev 2827)
@@ -781,6 +781,11 @@
movement_pred_ptr_list m_movement_predicates;
// -------- End movement support --------
+ // -------- Reputation support ---------
+public:
+ // Print statistics about reputation
+ void PrintReputationData(const cString& filename);
+
// -------- Deme replication support --------
public:
More information about the Avida-cvs
mailing list