[Avida-cvs] [avida-svn] r950 - in development: Avida.xcodeproj source/cpu

jclune at myxo.css.msu.edu jclune at myxo.css.msu.edu
Wed Sep 13 11:03:25 PDT 2006


Author: jclune
Date: 2006-09-13 14:03:24 -0400 (Wed, 13 Sep 2006)
New Revision: 950

Modified:
   development/Avida.xcodeproj/project.pbxproj
   development/source/cpu/cHardwareCPU.cc
   development/source/cpu/cHardwareCPU.h
Log:
Added an IO-Feedback instruction that puts a value (+1,0,-1) on the active stack if the merit goes up, stays the same, or goes down as a result of the previous IO

Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj	2006-09-13 17:53:45 UTC (rev 949)
+++ development/Avida.xcodeproj/project.pbxproj	2006-09-13 18:03:24 UTC (rev 950)
@@ -374,6 +374,23 @@
 		};
 /* End PBXBuildRule section */
 
+/* Begin PBXBuildStyle section */
+		B7D2AFCA0AB5146C002F9D48 /* Development */ = {
+			isa = PBXBuildStyle;
+			buildSettings = {
+				COPY_PHASE_STRIP = NO;
+			};
+			name = Development;
+		};
+		B7D2AFCB0AB5146C002F9D48 /* Deployment */ = {
+			isa = PBXBuildStyle;
+			buildSettings = {
+				COPY_PHASE_STRIP = YES;
+			};
+			name = Deployment;
+		};
+/* End PBXBuildStyle section */
+
 /* Begin PBXContainerItemProxy section */
 		70DCF67509D4E10500924128 /* PBXContainerItemProxy */ = {
 			isa = PBXContainerItemProxy;
@@ -1802,6 +1819,12 @@
 		DCC30C4D0762532C008F7A48 /* Project object */ = {
 			isa = PBXProject;
 			buildConfigurationList = 702442D70859E0B00059BD9B /* Build configuration list for PBXProject "Avida" */;
+			buildSettings = {
+			};
+			buildStyles = (
+				B7D2AFCA0AB5146C002F9D48 /* Development */,
+				B7D2AFCB0AB5146C002F9D48 /* Deployment */,
+			);
 			hasScannedForEncodings = 0;
 			mainGroup = DCC30C490762532C008F7A48;
 			productRefGroup = DCC3164E07626CF3008F7A48 /* Products */;

Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc	2006-09-13 17:53:45 UTC (rev 949)
+++ development/source/cpu/cHardwareCPU.cc	2006-09-13 18:03:24 UTC (rev 950)
@@ -209,6 +209,9 @@
     cInstEntryCPU("put",       &cHardwareCPU::Inst_TaskPut),
     cInstEntryCPU("IO",        &cHardwareCPU::Inst_TaskIO, true,
                   "Output ?BX?, and input new number back into ?BX?"),
+    cInstEntryCPU("IO-Feedback",        &cHardwareCPU::Inst_TaskIO_Feedback, true,\
+                  "Output ?BX?, and input new number back into ?BX?,  and push 1,0,\
+                  or -1 onto stack1 if merit increased, stayed the same, or decreased"),
     cInstEntryCPU("match-strings", &cHardwareCPU::Inst_MatchStrings),
 	cInstEntryCPU("sell", &cHardwareCPU::Inst_Sell),
 	cInstEntryCPU("buy", &cHardwareCPU::Inst_Buy),
@@ -622,6 +625,12 @@
     << "F-Head:" << GetHead(nHardware::HEAD_FLOW).GetPosition()   << "  "
     << "RL:" << GetReadLabel().AsString() << "   "
     << endl;
+    
+  int number_of_stacks = GetNumStacks();
+  for (int stack_id = 0; stack_id < number_of_stacks; stack_id++) {
+    fp << "Top of stack " << stack_id << ":"
+    << GetStack(0, stack_id, 0) << endl;
+  }
   
   fp << "  Mem (" << GetMemory().GetSize() << "):"
 		  << "  " << GetMemory().AsString()
@@ -2436,7 +2445,7 @@
   
   // Do the "put" component
   const int value_out = GetRegister(reg_used);
-  organism->DoOutput(ctx, value_out);  // Check for tasks compleated.
+  organism->DoOutput(ctx, value_out);  // Check for tasks completed.
   
   // Do the "get" component
   const int value_in = organism->GetNextInput();
@@ -2444,7 +2453,49 @@
   organism->DoInput(value_in);
   return true;
 }
+bool cHardwareCPU::Inst_TaskIO_Feedback(cAvidaContext& ctx)
+{
+  const int reg_used = FindModifiedRegister(REG_BX);
 
+  //check cur_bonus before the output
+  double preOutputBonus = organism->GetPhenotype().GetCurBonus();
+  
+  // Do the "put" component
+  const int value_out = GetRegister(reg_used);
+  organism->DoOutput(ctx, value_out);  // Check for tasks completed.
+
+  //check cur_merit after the output
+  double postOutputBonus = organism->GetPhenotype().GetCurBonus(); 
+  
+  
+  //push the effect of the IO on merit (+,0,-) to the active stack
+
+  if (preOutputBonus > postOutputBonus){
+    StackPush(-1);
+    }
+  else if (preOutputBonus == postOutputBonus){
+    StackPush(0);
+    }
+  else if (preOutputBonus < postOutputBonus){
+    StackPush(1);
+    }
+  else {
+    assert(0);
+    //Bollocks. There was an error.
+    }
+
+
+  
+
+
+  
+  // Do the "get" component
+  const int value_in = organism->GetNextInput();
+  GetRegister(reg_used) = value_in;
+  organism->DoInput(value_in);
+  return true;
+}
+
 bool cHardwareCPU::Inst_MatchStrings(cAvidaContext& ctx)
 {
 	if (m_executedmatchstrings)

Modified: development/source/cpu/cHardwareCPU.h
===================================================================
--- development/source/cpu/cHardwareCPU.h	2006-09-13 17:53:45 UTC (rev 949)
+++ development/source/cpu/cHardwareCPU.h	2006-09-13 18:03:24 UTC (rev 950)
@@ -376,6 +376,7 @@
   bool Inst_TaskStackLoad(cAvidaContext& ctx);
   bool Inst_TaskPut(cAvidaContext& ctx);
   bool Inst_TaskIO(cAvidaContext& ctx);
+  bool Inst_TaskIO_Feedback(cAvidaContext& ctx);
   bool Inst_MatchStrings(cAvidaContext& ctx);
   bool Inst_Sell(cAvidaContext& ctx);
   bool Inst_Buy(cAvidaContext& ctx);




More information about the Avida-cvs mailing list