[Avida-SVN] r3293 - in branches/matt/CompeteInstSet/source: actions cpu
ruppmatt at myxo.css.msu.edu
ruppmatt at myxo.css.msu.edu
Fri Jun 5 14:04:52 PDT 2009
Author: ruppmatt
Date: 2009-06-05 17:04:52 -0400 (Fri, 05 Jun 2009)
New Revision: 3293
Modified:
branches/matt/CompeteInstSet/source/actions/PopulationActions.cc
branches/matt/CompeteInstSet/source/cpu/cHardwareManager.cc
Log:
Added add_inst_set population action. Fixed a bug in cHardwareManager when comparing two cInstSets
Modified: branches/matt/CompeteInstSet/source/actions/PopulationActions.cc
===================================================================
--- branches/matt/CompeteInstSet/source/actions/PopulationActions.cc 2009-06-05 20:22:28 UTC (rev 3292)
+++ branches/matt/CompeteInstSet/source/actions/PopulationActions.cc 2009-06-05 21:04:52 UTC (rev 3293)
@@ -1524,6 +1524,31 @@
};
+class cActionAddInstSet : public cAction
+{
+ private:
+ cString m_filename;
+ int m_id;
+ public:
+ cActionAddInstSet(cWorld* world, const cString& args) : cAction(world, args)
+ {
+ cString largs(args);
+ m_filename = (largs.GetSize()) ? largs.PopWord() : "-";
+ m_id = (largs.GetSize()) ? largs.PopWord().AsInt() : 0;
+ }
+
+ static const cString GetDescription() { return "Arguments: <path> <id>"; }
+
+ void Process(cAvidaContext& ctx)
+ {
+ if (!m_world->GetHardwareManager().AddInstSet(m_filename, m_id))
+ m_world->GetDriver().RaiseException("cAddInstSet has failed.");
+ else
+ cerr << "Added inst_set " << m_filename << " as " << m_id << endl;
+ }
+};
+
+
void RegisterPopulationActions(cActionLibrary* action_lib)
{
action_lib->Register<cActionInject>("Inject");
@@ -1597,4 +1622,6 @@
action_lib->Register<cActionConnectCells>("connect_cells");
action_lib->Register<cActionDisconnectCells>("disconnect_cells");
action_lib->Register<cActionSwapCells>("swap_cells");
+
+ action_lib->Register<cActionAddInstSet>("add_inst_set");
}
Modified: branches/matt/CompeteInstSet/source/cpu/cHardwareManager.cc
===================================================================
--- branches/matt/CompeteInstSet/source/cpu/cHardwareManager.cc 2009-06-05 20:22:28 UTC (rev 3292)
+++ branches/matt/CompeteInstSet/source/cpu/cHardwareManager.cc 2009-06-05 21:04:52 UTC (rev 3293)
@@ -103,8 +103,7 @@
new_inst_set->LoadFromLegacyFile(filename);
}
- cerr << m_inst_sets.GetSize() << endl;
- if (m_inst_sets.GetSize() == 0 || m_inst_sets[0] == new_inst_set){
+ if (m_inst_sets.GetSize() == 0 || (*m_inst_sets[0] == *new_inst_set) ){
if (id <= m_inst_sets.GetSize() - 1){ //If our array is large enough
if (m_inst_sets[id] != NULL) //Old instruction set exists, delete it
delete m_inst_sets[id];
More information about the Avida-cvs
mailing list