[Avida-SVN] r1919 - in branches/energy/source: cpu main
beckma24 at myxo.css.msu.edu
beckma24 at myxo.css.msu.edu
Thu Aug 9 11:28:34 PDT 2007
Author: beckma24
Date: 2007-08-09 14:28:33 -0400 (Thu, 09 Aug 2007)
New Revision: 1919
Modified:
branches/energy/source/cpu/cHardwareBase.cc
branches/energy/source/cpu/cHardwareBase.h
branches/energy/source/cpu/cHardwareCPU.cc
branches/energy/source/main/cPhenotype.h
Log:
Added instruction methods that allow all hardware types to double/half the current amount of energy used by an organism
Modified: branches/energy/source/cpu/cHardwareBase.cc
===================================================================
--- branches/energy/source/cpu/cHardwareBase.cc 2007-08-09 18:08:29 UTC (rev 1918)
+++ branches/energy/source/cpu/cHardwareBase.cc 2007-08-09 18:28:33 UTC (rev 1919)
@@ -756,6 +756,17 @@
return false;
}
+bool cHardwareBase::Inst_DoubleEnergyUsage(cAvidaContext& ctx) {
+ organism->GetPhenotype().DoubleEnergyUsage();
+ return true;
+}
+
+bool cHardwareBase::Inst_HalfEnergyUsage(cAvidaContext& ctx) {
+ organism->GetPhenotype().HalfEnergyUsage();
+ return true;
+}
+
+
// This method will test to see if all costs have been paid associated
// with executing an instruction and only return true when that instruction
// should proceed.
Modified: branches/energy/source/cpu/cHardwareBase.h
===================================================================
--- branches/energy/source/cpu/cHardwareBase.h 2007-08-09 18:08:29 UTC (rev 1918)
+++ branches/energy/source/cpu/cHardwareBase.h 2007-08-09 18:28:33 UTC (rev 1919)
@@ -184,6 +184,10 @@
// -------- Implicit Repro Check/Instruction -------- @JEB
void CheckImplicitRepro(cAvidaContext& ctx);
virtual bool Inst_Repro(cAvidaContext& ctx);
+
+ // -------- Execution Speed Instruction --------
+ bool Inst_DoubleEnergyUsage(cAvidaContext& ctx);
+ bool Inst_HalfEnergyUsage(cAvidaContext& ctx);
};
Modified: branches/energy/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/energy/source/cpu/cHardwareCPU.cc 2007-08-09 18:08:29 UTC (rev 1918)
+++ branches/energy/source/cpu/cHardwareCPU.cc 2007-08-09 18:28:33 UTC (rev 1919)
@@ -359,6 +359,10 @@
tInstLibEntry<tMethod>("promoter", &cHardwareCPU::Inst_Promoter),
tInstLibEntry<tMethod>("decay-reg", &cHardwareCPU::Inst_DecayRegulation),
+ // Energy usage
+ tInstLibEntry<tMethod>("double-energy-usage", &cHardwareCPU::Inst_DoubleEnergyUsage),
+ tInstLibEntry<tMethod>("half-energy-usage", &cHardwareCPU::Inst_HalfEnergyUsage),
+
// Placebo instructions
tInstLibEntry<tMethod>("skip", &cHardwareCPU::Inst_Skip),
Modified: branches/energy/source/main/cPhenotype.h
===================================================================
--- branches/energy/source/main/cPhenotype.h 2007-08-09 18:08:29 UTC (rev 1918)
+++ branches/energy/source/main/cPhenotype.h 2007-08-09 18:28:33 UTC (rev 1919)
@@ -465,8 +465,8 @@
bool& ChildFertile() { assert(initialized == true); return child_fertile; }
bool& IsMultiThread() { assert(initialized == true); return is_multi_thread; }
- void DoubleExecutionSpeed() { executionRatio *= 2.0; }
- void HalfExecutionSpeed() { executionRatio *= 0.5; }
+ void DoubleEnergyUsage() { executionRatio *= 2.0; }
+ void HalfEnergyUsage() { executionRatio *= 0.5; }
void RefreshEnergy();
void ApplyToEnergyStore();
double ExtractParentEnergy();
More information about the Avida-cvs
mailing list