[Avida-SVN] r3584 - branches/matt/InheritInstSet/source/main
ruppmatt at myxo.css.msu.edu
ruppmatt at myxo.css.msu.edu
Tue Jan 5 12:45:03 PST 2010
Author: ruppmatt
Date: 2010-01-05 15:45:03 -0500 (Tue, 05 Jan 2010)
New Revision: 3584
Modified:
branches/matt/InheritInstSet/source/main/cInheritedInstSet.cpp
branches/matt/InheritInstSet/source/main/cInheritedInstSet.h
Log:
Fixing some casting issues.
Modified: branches/matt/InheritInstSet/source/main/cInheritedInstSet.cpp
===================================================================
--- branches/matt/InheritInstSet/source/main/cInheritedInstSet.cpp 2010-01-05 00:46:32 UTC (rev 3583)
+++ branches/matt/InheritInstSet/source/main/cInheritedInstSet.cpp 2010-01-05 20:45:03 UTC (rev 3584)
@@ -14,10 +14,8 @@
#include <cassert>
-cInheritedInstSet::cInheritedInstSet(const cInheritedInstSet* in) : cInstSet(* ((cInstSet*) in) )
+cInheritedInstSet::cInheritedInstSet(const cInheritedInstSet* in) : cInstSet(*in)
{
-
- m_redundancies = in->m_redundancies;
m_allowed_redundancies = in->m_allowed_redundancies;
}
@@ -28,9 +26,7 @@
m_allowed_redundancies = allowed_redundancies;
if (init_val == 0)
InitRedRandomly();
- else if (init_val < 0)
- InitRedByBaseInstSet();
- else
+ else if (init_val > 0)
InitRedByValue(init_val);
Sync();
}
@@ -39,29 +35,17 @@
void cInheritedInstSet::InitRedRandomly()
{
- m_redundancies = tArray<int>(m_allowed_redundancies.GetSize(),-1);
- for (int x = 0; x < m_redundancies.GetSize(); x++)
- m_redundancies[x] = GetRandomRedundancy(x);
+ for (int x = 0; x < m_lib_name_map.GetSize(); x++)
+ m_lib_name_map[x].redundancy = GetRandomRedundancy(x);
return;
}
-void cInheritedInstSet::InitRedByBaseInstSet()
-{
- m_redundancies = tArray<int>(m_allowed_redundancies.GetSize(), -1);
- for (int id = 0; id < m_lib_name_map.GetSize(); id++){
- m_redundancies[id] = m_lib_name_map[id].redundancy;
- }
- return;
-}
-
-
void cInheritedInstSet::InitRedByValue(int val)
{
- m_redundancies = tArray<int>(m_allowed_redundancies.GetSize(), -1);
- for (int x = 0; x < m_redundancies.GetSize(); x++){
- m_redundancies[x] = val;
+ for (int x = 0; x < m_lib_name_map.GetSize(); x++){
+ m_lib_name_map[x].redundancy = GetRandomRedundancy(x);
}
return;
}
@@ -86,9 +70,9 @@
bool cInheritedInstSet::MutateAllInsts(double p)
{
bool did_mutate = false;
- for (int id = 0; id < m_redundancies.GetSize(); id++)
+ for (int id = 0; id < m_lib_name_map.GetSize(); id++)
if (RandProceed(p)){
- m_redundancies[id] = GetRandomRedundancy(id);
+ m_lib_name_map[id].redundancy = GetRandomRedundancy(id);
did_mutate = true;
}
return did_mutate;
@@ -97,8 +81,8 @@
bool cInheritedInstSet::MutateSingleInst()
{
- int id = m_world->GetRandom().GetUInt(0,m_redundancies.GetSize());
- m_redundancies[id] = GetRandomRedundancy(id);
+ int id = m_world->GetRandom().GetUInt(0,m_lib_name_map.GetSize());
+ m_lib_name_map[id].redundancy = GetRandomRedundancy(id);
return true;
}
@@ -107,13 +91,13 @@
void cInheritedInstSet::Sync()
{
int sum = 0;
- for (int x = 0; x < m_redundancies.GetSize(); x++)
- sum += m_redundancies[x];
+ for (int x = 0; x < m_lib_name_map.GetSize(); x++)
+ sum += m_lib_name_map[x].redundancy;
assert(sum <= 255);
m_mutation_chart = tArray<int>(sum, -1);
int ndx = 0;
- for (int id = 0; id < m_redundancies.GetSize(); id++)
- for (int n = 0; n < m_redundancies[id]; n++)
+ for (int id = 0; id < m_lib_name_map.GetSize(); id++)
+ for (int n = 0; n < m_lib_name_map[id].redundancy; n++)
m_mutation_chart[ndx++] = id;
}
Modified: branches/matt/InheritInstSet/source/main/cInheritedInstSet.h
===================================================================
--- branches/matt/InheritInstSet/source/main/cInheritedInstSet.h 2010-01-05 00:46:32 UTC (rev 3583)
+++ branches/matt/InheritInstSet/source/main/cInheritedInstSet.h 2010-01-05 20:45:03 UTC (rev 3584)
@@ -23,7 +23,6 @@
class cInheritedInstSet : public cInstSet{
private:
- tArray<int> m_redundancies;
tArray< tArray<int> > m_allowed_redundancies;
void InitRedRandomly();
More information about the Avida-cvs
mailing list