[Avida-SVN] r3087 - in branches/hjg-dev/source: cpu main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Sat Jan 3 08:52:18 PST 2009
Author: hjg
Date: 2009-01-03 11:52:18 -0500 (Sat, 03 Jan 2009)
New Revision: 3087
Modified:
branches/hjg-dev/source/cpu/cHardwareCPU.cc
branches/hjg-dev/source/main/cStats.cc
branches/hjg-dev/source/main/cTaskLib.cc
Log:
Modified MatchString task to work with Produce string. Added stats for generalists and specialists. Modified sense instructions to work with the new method of tracking strings.
Modified: branches/hjg-dev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.cc 2008-12-31 16:20:23 UTC (rev 3086)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.cc 2009-01-03 16:52:18 UTC (rev 3087)
@@ -7207,15 +7207,16 @@
bool cHardwareCPU::Inst_GetAmountOfRawMaterials(cAvidaContext& ctx)
{
const int raw_mat_reg = FindModifiedRegister(REG_AX);
- GetRegister(raw_mat_reg) = organism->GetSelfRawMaterials();
+ GetRegister(raw_mat_reg) = organism->GetNumberStringsOnHand(0);
return true;
}
-
+/* Sense the number of raw materials an organism has. Store in
+ ?REG_BX? */
bool cHardwareCPU::Inst_GetAmountOfOtherRawMaterials(cAvidaContext& ctx)
{
- const int raw_mat_reg = FindModifiedRegister(REG_AX);
- GetRegister(raw_mat_reg) = organism->GetOtherRawMaterials();
+ const int raw_mat_reg = FindModifiedRegister(REG_BX);
+ GetRegister(raw_mat_reg) = organism->GetNumberStringsOnHand(1);
return true;
}
Modified: branches/hjg-dev/source/main/cStats.cc
===================================================================
--- branches/hjg-dev/source/main/cStats.cc 2008-12-31 16:20:23 UTC (rev 3086)
+++ branches/hjg-dev/source/main/cStats.cc 2009-01-03 16:52:18 UTC (rev 3087)
@@ -1821,6 +1821,10 @@
int onhand = 0;
int instant_perfect_match = 0;
int instant_perfect_match_org = 0;
+ int nothing =0;
+ int specialists = 0;
+ int generalists = 0;
+ int type_prod = 0;
// Get the number of strings
int num = m_world->GetEnvironment().GetNumberOfMatchStrings();
@@ -1829,9 +1833,10 @@
org = cell.GetOrganism();
min = -1;
onhand = 0;
+ type_prod = 0;
if(cell.IsOccupied()) {
- for (unsigned int j = 0; j<num; j++) {
+ for (int j = 0; j<num; j++) {
onhand = org->GetNumberStringsOnHand(j);
if ((min == -1) || (onhand < min)){
min = onhand;
@@ -1839,12 +1844,18 @@
m_strings_stored[j].Add(onhand);
total.Add(onhand);
m_strings_produced[j].Add(org->GetNumberStringsProduced(j));
+
+ if (org->GetNumberStringsProduced(j)) type_prod++;
+
}
instant_perfect_match += min;
if (min > 0) instant_perfect_match_org++;
-
+ if (type_prod ==0) nothing++;
+ if (type_prod == 1) specialists++;
+ if (type_prod > 1) generalists++;
}
+
}
// print the string info
@@ -1869,6 +1880,9 @@
df.Write(instant_perfect_match, "PerfectMatchStringInstant[psi]");
// Print number of perfect matches
df.Write(instant_perfect_match_org, "PerfectMatchOrgInstant[psoi]");
+ df.Write(nothing, "Producednothing[nothing]");
+ df.Write(generalists, "Generalists[generalists]");
+ df.Write(specialists, "Specialists[specialists]");
df.Endl();
@@ -1888,8 +1902,6 @@
cDoubleSum num_failed_reputation_inc;
cDoubleSum own_raw_mat;
cDoubleSum other_raw_mat;
- int num_all_strings = 0;
- int num_strings = m_world->GetEnvironment().GetNumberOfMatchStrings() -1;
// difference between how many an organism donated & how many it received
@@ -1899,7 +1911,6 @@
int min_rep = 100;
int max_rep = 0;
int cur_rep;
-// int pop_size = 0;
int num_alt =0;
int num_coop = 0;
@@ -1915,7 +1926,6 @@
org = cell.GetOrganism();
if(cell.IsOccupied()) {
-// const tArray<int>& org_rx = cell.GetOrganism()->GetPhenotype().GetCurReactionCount();
cur_rep = org->GetReputation();
if (cur_rep < min_rep) min_rep = cur_rep;
@@ -1931,18 +1941,15 @@
donors.Add(org->GetNumberOfDonors());
num_failed_reputation_inc.Add(org->GetFailedReputationIncreases());
k.Add(org->GetK());
-// pop_size++;
disparity.Add(org->GetNumberOfDonations() - org->GetOtherRawMaterials());
if (org->GetNumberOfDonations() > 0) num_alt++;
if ((org->GetNumberOfDonationsReceived() && org->GetNumberOfDonations()) > 0) num_coop++;
-// if (org->GetNumberOfDonatedLineages() == num_strings) num_all_strings++;
}
}
-// float rep = reputations/pop_size;
df.Write(reputations.Average(), "Avg. reputation [reputation]");
// df.Write(reputations.StdDeviation(), "Standard Deviation [repstddev]");
// df.Write(min_rep, "Minimum reputation");
Modified: branches/hjg-dev/source/main/cTaskLib.cc
===================================================================
--- branches/hjg-dev/source/main/cTaskLib.cc 2008-12-31 16:20:23 UTC (rev 3086)
+++ branches/hjg-dev/source/main/cTaskLib.cc 2009-01-03 16:52:18 UTC (rev 3087)
@@ -1999,8 +1999,13 @@
}
- // Update the organism's tag.
+ // Check if the organism already produced this string.
+ // If so, it receives a perfect score for this task.
int tag = ctx.GetTaskEntry()->GetArguments().GetInt(2);
+ int prod = ctx.GetOrganism()->GetNumberStringsProduced(tag);
+ if (prod) max_num_matched = string_to_match.GetSize();
+
+ // Update the organism's tag.
ctx.GetOrganism()->UpdateTag(tag, max_num_matched);
if (ctx.GetOrganism()->GetTagLabel() == tag) {
ctx.GetOrganism()->SetLineageLabel(ctx.GetTaskEntry()->GetArguments().GetInt(2));
@@ -2023,15 +2028,8 @@
double bonus = 0.0;
double base_bonus = 0.0;
- //if (m_world->GetConfig().MATCH_PERCENT.Get() == 0) {
- // percent over 50% (Sherri)
- base_bonus = static_cast<double>(max_num_matched) * 2.0 / static_cast<double>(string_to_match.GetSize()) - 1;
-// } else if (m_world->GetConfig().MATCH_PERCENT.Get() == 1) {
- // percent (hjg)
- // base_bonus = static_cast<double>(max_num_matched) / static_cast<double>(string_to_match.GetSize());
- //}
+ base_bonus = static_cast<double>(max_num_matched) * 2.0 / static_cast<double>(string_to_match.GetSize()) - 1;
-
if (partial)
{
base_bonus=double(max_num_matched)*2/double(num_real) -1;
More information about the Avida-cvs
mailing list