[Avida-SVN] r2856 - in branches/hjg-dev/source: cpu main

hjg at myxo.css.msu.edu hjg at myxo.css.msu.edu
Mon Oct 20 09:55:36 PDT 2008


Author: hjg
Date: 2008-10-20 12:55:35 -0400 (Mon, 20 Oct 2008)
New Revision: 2856

Modified:
   branches/hjg-dev/source/cpu/cHardwareCPU.cc
   branches/hjg-dev/source/main/cOrganism.cc
   branches/hjg-dev/source/main/cOrganism.h
Log:
fixed bug in praise/punish instructions.

Modified: branches/hjg-dev/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/hjg-dev/source/cpu/cHardwareCPU.cc	2008-10-19 03:34:02 UTC (rev 2855)
+++ branches/hjg-dev/source/cpu/cHardwareCPU.cc	2008-10-20 16:55:35 UTC (rev 2856)
@@ -6861,15 +6861,20 @@
 bool cHardwareCPU::Inst_PunishNeighbor(cAvidaContext& ctx) 
 {
 	cOrganism * neighbor = organism->GetNeighbor();
-	if (neighbor == NULL) return true;
+	if (neighbor != NULL) {
+		int rep = neighbor->GetReputation();
+		neighbor->SetReputation(rep-1);
+	}
 
 	// improve neighbor reputation
-	if (neighbor->HasOpinion()) {
+/*	if (neighbor->HasOpinion()) {
 		int opinion = neighbor->GetOpinion().first - 1;
 		neighbor->SetOpinion(opinion);
 	} else {
 		neighbor->SetOpinion(-1);
-	}
+	}*/
+	
+	
 	return true;
 }
 
@@ -6877,7 +6882,11 @@
 bool cHardwareCPU::Inst_PraiseNeighbor(cAvidaContext& ctx) 
 {
 	cOrganism * neighbor = organism->GetNeighbor();
-	if (neighbor == NULL) return true;
+	if (neighbor != NULL) {
+		int rep = neighbor->GetReputation();
+		neighbor->SetReputation(rep+1);
+	}
+	/*if (neighbor == NULL) return true;
 	 
 	// improve neighbor reputation
 	if (neighbor->HasOpinion()) {
@@ -6885,7 +6894,7 @@
 		neighbor->SetOpinion(opinion);
 	} else {
 		neighbor->SetOpinion(1);
-	}
+	}*/
 	return true;
 }
 

Modified: branches/hjg-dev/source/main/cOrganism.cc
===================================================================
--- branches/hjg-dev/source/main/cOrganism.cc	2008-10-19 03:34:02 UTC (rev 2855)
+++ branches/hjg-dev/source/main/cOrganism.cc	2008-10-20 16:55:35 UTC (rev 2856)
@@ -804,6 +804,11 @@
 	return rep;
 }
 
+/* Set an organism's reputation */
+void cOrganism::SetReputation(int rep) {
+	SetOpinion(rep);
+	return;
+}
 
 /* Increase an organism's probability of donating by 10% 
 	Essentially, the reputation can vary from 0-10, where 0

Modified: branches/hjg-dev/source/main/cOrganism.h
===================================================================
--- branches/hjg-dev/source/main/cOrganism.h	2008-10-19 03:34:02 UTC (rev 2855)
+++ branches/hjg-dev/source/main/cOrganism.h	2008-10-20 16:55:35 UTC (rev 2856)
@@ -456,6 +456,8 @@
 	int GetOtherRawMaterials() { return m_other_raw_materials; }
 	// get the organism's reputation
 	int GetReputation(); 
+	// set the organism's reputation
+	void SetReputation(int rep);
 	// get number of donors
 	int GetNumberOfDonors() { return donor_list.size(); }
 	// increase reciprocation probability




More information about the Avida-cvs mailing list