[avida-cvs] avida(kaben) CVS commits: /current/source defs.hh /current/source/cpu hardware_4stack.cc hardware_cpu.cc /current/source/main inst_set.cc inst_set.hh
kaben
avida-cvs at alife.org
Fri May 23 11:17:42 PDT 2003
kaben Fri May 23 03:17:42 2003 EDT
Modified files: (Branch: kaben)
/avida/current/source defs.hh
/avida/current/source/cpu hardware_4stack.cc hardware_cpu.cc
/avida/current/source/main inst_set.cc inst_set.hh
Log:
Isolating some data structures used in new inst_set code (to trigger
compiler errors when they're used an shouldn't be).
Index: avida/current/source/defs.hh
diff -u avida/current/source/defs.hh:1.25.2.3 avida/current/source/defs.hh:1.25.2.4
--- avida/current/source/defs.hh:1.25.2.3 Fri May 23 02:36:34 2003
+++ avida/current/source/defs.hh Fri May 23 03:17:39 2003
@@ -18,7 +18,7 @@
#define HTMLDIR "../work/doc_html/"
#endif
-//#define USE_INST_SET_CODE
+#define USE_INST_SET_CODE
// -= Various view modes =-
#define VIEW_NEWVIEWER
Index: avida/current/source/cpu/hardware_4stack.cc
diff -u avida/current/source/cpu/hardware_4stack.cc:1.2.2.3 avida/current/source/cpu/hardware_4stack.cc:1.2.2.4
--- avida/current/source/cpu/hardware_4stack.cc:1.2.2.3 Fri May 23 02:36:34 2003
+++ avida/current/source/cpu/hardware_4stack.cc Fri May 23 03:17:40 2003
@@ -552,8 +552,12 @@
#ifdef EXECUTION_ERRORS
// If there is an execution error, execute a random instruction.
+#ifdef USE_INST_SET_CODE
+ if (organism->TestExeErr()) inst_idx = GetInstSet().GetRandFunctionIndex();
+#else /* USE_INST_SET_CODE */
if (organism->TestExeErr()) inst_ptr = GetInstSet().GetRandFunction();
-#endif
+#endif /* USE_INST_SET_CODE */
+#endif /* EXECUTION_ERRORS */
#ifdef INSTRUCTION_COUNT
// instruction execution count incremeneted
Index: avida/current/source/cpu/hardware_cpu.cc
diff -u avida/current/source/cpu/hardware_cpu.cc:1.34.2.4 avida/current/source/cpu/hardware_cpu.cc:1.34.2.5
--- avida/current/source/cpu/hardware_cpu.cc:1.34.2.4 Fri May 23 02:36:34 2003
+++ avida/current/source/cpu/hardware_cpu.cc Fri May 23 03:17:41 2003
@@ -663,8 +663,12 @@
#ifdef EXECUTION_ERRORS
// If there is an execution error, execute a random instruction.
+#ifdef USE_INST_SET_CODE
+ if (organism->TestExeErr()) inst_idx = GetInstSet().GetRandFunctionIndex();
+#else /* USE_INST_SET_CODE */
if (organism->TestExeErr()) inst_ptr = GetInstSet().GetRandFunction();
-#endif
+#endif /* USE_INST_SET_CODE */
+#endif /* EXECUTION_ERRORS */
#ifdef INSTRUCTION_COUNT
// instruction execution count incremeneted
Index: avida/current/source/main/inst_set.cc
diff -u avida/current/source/main/inst_set.cc:1.1.2.2 avida/current/source/main/inst_set.cc:1.1.2.3
--- avida/current/source/main/inst_set.cc:1.1.2.2 Fri May 23 02:36:35 2003
+++ avida/current/source/main/inst_set.cc Fri May 23 03:17:41 2003
@@ -32,12 +32,21 @@
{
}
+#ifdef USE_INST_SET_CODE
+cInstSet::cInstSet(const cInstSet & in_inst_set)
+ : m_lib_name_map(in_inst_set.m_lib_name_map)
+ , m_lib_nopmod_map(in_inst_set.m_lib_nopmod_map)
+ , mutation_chart2(in_inst_set.mutation_chart2)
+{
+}
+#else /* USE_INST_SET_CODE */
cInstSet::cInstSet(const cInstSet & in_inst_set)
: inst_array(in_inst_set.inst_array)
, nop_mods(in_inst_set.nop_mods)
, mutation_chart(in_inst_set.mutation_chart)
{
}
+#endif /* USE_INST_SET_CODE */
cInstSet::~cInstSet()
{
@@ -215,8 +224,13 @@
int best_dist = 1024;
cString best_name("");
+#ifdef USE_INST_SET_CODE
+ for (int i = 0; i < m_lib_name_map.GetSize(); i++) {
+ const cString & cur_name = m_inst_lib->GetName(m_lib_name_map[i].lib_fun_id);
+#else /* USE_INST_SET_CODE */
for (int i = 0; i < inst_array.GetSize(); i++) {
const cString & cur_name = inst_array[i].name;
+#endif /* USE_INST_SET_CODE */
const int cur_dist = cStringUtil::EditDistance(cur_name, in_name);
if (cur_dist < best_dist) {
best_dist = cur_dist;
Index: avida/current/source/main/inst_set.hh
diff -u avida/current/source/main/inst_set.hh:1.1.2.2 avida/current/source/main/inst_set.hh:1.1.2.3
--- avida/current/source/main/inst_set.hh:1.1.2.2 Fri May 23 02:36:35 2003
+++ avida/current/source/main/inst_set.hh Fri May 23 03:17:41 2003
@@ -35,6 +35,7 @@
**/
class cInstSet {
+#ifdef USE_INST_SET_CODE
public:
cInstLibBase *m_inst_lib;
class cInstEntry2 {
@@ -52,6 +53,7 @@
static cInstruction inst_error2;
// static const cInstruction inst_none;
static cInstruction inst_default2;
+#else /* USE_INST_SET_CODE */
private:
// This class gives full info about a single instruction in the library.
class cInstEntry {
@@ -67,13 +69,13 @@
tArray<cInstEntry> inst_array; // The instructions indexed by ID
tArray<int> nop_mods; // Modification table for nops
tArray<int> mutation_chart; // ID's represented by redundancy values.
+#endif /* USE_INST_SET_CODE */
// Static components...
static const cInstruction inst_error;
// static const cInstruction inst_none;
static const cInstruction inst_default;
-
public:
cInstSet();
cInstSet(const cInstSet & in_inst_set);
@@ -165,11 +167,17 @@
}
cInstruction GetRandomInst() const;
- /* FIXME: provide equivalent for USE_INST_SET_CODE section -- kgn */
+#ifdef USE_INST_SET_CODE
+ int GetRandFunctionIndex() const
+ {
+ return m_lib_name_map[ GetRandomInst().GetOp() ].lib_fun_id;
+ }
+#else /* USE_INST_SET_CODE */
tHardwareMethod GetRandFunction() const
{
return inst_array[ GetRandomInst().GetOp() ].function;
}
+#endif /* USE_INST_SET_CODE */
int GetSize() const {
#ifdef USE_INST_SET_CODE
More information about the Avida-cvs
mailing list