[Avida-SVN] r2743 - in branches/interrupt/source: classification cpu main
beckma24 at myxo.css.msu.edu
beckma24 at myxo.css.msu.edu
Sat Aug 23 08:25:35 PDT 2008
Author: beckma24
Date: 2008-08-06 15:22:06 -0400 (Wed, 06 Aug 2008)
New Revision: 2743
Modified:
branches/interrupt/source/classification/cGenotype.cc
branches/interrupt/source/cpu/cHardwareBase.cc
branches/interrupt/source/main/cGenome.cc
Log:
site_protection++
Modified: branches/interrupt/source/classification/cGenotype.cc
===================================================================
--- branches/interrupt/source/classification/cGenotype.cc 2008-08-05 16:18:59 UTC (rev 2742)
+++ branches/interrupt/source/classification/cGenotype.cc 2008-08-06 19:22:06 UTC (rev 2743)
@@ -99,7 +99,7 @@
int inst_op;
fp >> inst_op;
temp_inst.SetOp(static_cast<unsigned char>(inst_op));
- ret->genome[i] = temp_inst;
+ ret->genome.SetInst(i, temp_inst, false);
// @CAO add something here to load arguments for instructions.
}
Modified: branches/interrupt/source/cpu/cHardwareBase.cc
===================================================================
--- branches/interrupt/source/cpu/cHardwareBase.cc 2008-08-05 16:18:59 UTC (rev 2742)
+++ branches/interrupt/source/cpu/cHardwareBase.cc 2008-08-06 19:22:06 UTC (rev 2743)
@@ -172,15 +172,15 @@
switch (m_world->GetConfig().SLIP_FILL_MODE.Get())
{
case 0:
- child_genome[from+i] = child_copy[to+i];
+ child_genome.SetInst(from+i, child_copy[to+i], child_copy.IsProtected(to+i));
break;
case 1:
- child_genome[from+i] = m_inst_set->GetInst("nop-X");
+ child_genome.SetInst(from+i, m_inst_set->GetInst("nop-X"), false);
break;
case 2:
- child_genome[from+i] = m_inst_set->GetRandomInst(ctx);
+ child_genome.SetInst(from+i, m_inst_set->GetRandomInst(ctx), false);
break;
//Randomized order of instructions
@@ -201,7 +201,7 @@
}
test++;
}
- child_genome[from+i] = child_genome[to+copy_index];
+ child_genome.SetInst(from+i, child_genome[to+copy_index], child_genome.IsProtected(to+copy_index));
copied_so_far[copy_index] = true;
}
break;
@@ -217,7 +217,7 @@
if (insertion_length < 0) insertion_length = 0;
for (int i=insertion_length; i < child_copy.GetSize() - to; i++)
{
- child_genome[from+i] = child_copy[to+i];
+ child_genome.SetInst(from+i, child_copy[to+i], child_copy.IsProtected(to+i));
}
@@ -233,7 +233,7 @@
// Divide Mutations
if (organism->TestDivideMut(ctx) && totalMutations < maxmut) {
const unsigned int mut_line = ctx.GetRandom().GetUInt(child_genome.GetSize());
- child_genome[mut_line] = m_inst_set->GetRandomInst(ctx);
+ child_genome.SetInst(mut_line, m_inst_set->GetRandomInst(ctx), false);
// ++cpu_stats.mut_stats.divide_mut_count;
totalMutations++;
//cerr << "Mutating HERE!!!! BAD!!!!!" << endl;
@@ -263,7 +263,7 @@
if (num_mut > 0 && totalMutations < maxmut) {
for (int i = 0; i < num_mut && totalMutations < maxmut; i++) {
int site = ctx.GetRandom().GetUInt(child_genome.GetSize());
- child_genome[site] = m_inst_set->GetRandomInst(ctx);
+ child_genome.SetInst(site, m_inst_set->GetRandomInst(ctx), false);
// ++cpu_stats.mut_stats.div_mut_count;
totalMutations++;
}
@@ -336,7 +336,7 @@
if (mut < m_inst_set->GetSize()) { // point
int site = ctx.GetRandom().GetUInt(child_genome.GetSize());
- child_genome[site] = cInstruction(mut);
+ child_genome.SetInst(site, cInstruction(mut), false);
} else if (mut == m_inst_set->GetSize()) { // delete
if (child_genome.GetSize() == MIN_CREATURE_SIZE) continue;
int site = ctx.GetRandom().GetUInt(child_genome.GetSize());
@@ -359,7 +359,7 @@
if (organism->GetParentMutProb() > 0 && totalMutations < maxmut) {
for (int i = 0; i < GetMemory().GetSize(); i++) {
if (organism->TestParentMut(ctx)) {
- GetMemory()[i] = m_inst_set->GetRandomInst(ctx);
+ GetMemory().SetInst(i, m_inst_set->GetRandomInst(ctx), false);
// cpu_stats.mut_stats.parent_mut_line_count++;
totalMutations++; //Unlike the others we can't be sure this was done only on divide -- AWC 06/29/06
@@ -399,7 +399,7 @@
// Divide Mutations
if (totalMutations < maxmut) {
const unsigned int mut_line = ctx.GetRandom().GetUInt(child_genome.GetSize());
- child_genome[mut_line] = m_inst_set->GetRandomInst(ctx);
+ child_genome.SetInst(mut_line, m_inst_set->GetRandomInst(ctx), false);
// ++cpu_stats.mut_stats.divide_mut_count;
totalMutations++;
//cerr << "Mutating HERE!!!! BAD!!!!!" << endl;
@@ -414,7 +414,7 @@
if (num_mut > 0 && totalMutations < maxmut) {
for (int i = 0; i < num_mut && totalMutations < maxmut; i++) {
int site = ctx.GetRandom().GetUInt(child_genome.GetSize());
- child_genome[site] = m_inst_set->GetRandomInst(ctx);
+ child_genome.SetInst(site, m_inst_set->GetRandomInst(ctx), false);
// ++cpu_stats.mut_stats.div_mut_count;
totalMutations++;
cerr << "Resampling here " << totalMutations << endl;
@@ -572,7 +572,7 @@
for (int i = 0; i < num_muts; i++) {
const int pos = ctx.GetRandom().GetUInt(memory.GetSize());
- memory[pos] = m_inst_set->GetRandomInst(ctx);
+ memory.SetInst(pos, m_inst_set->GetRandomInst(ctx), false);
memory.SetFlagMutated(pos);
memory.SetFlagPointMut(pos);
// organism->CPUStats().mut_stats.point_mut_count++;
@@ -587,7 +587,7 @@
switch (type) {
case nMutation::TYPE_POINT:
- target_memory[pos] = m_inst_set->GetRandomInst(ctx);
+ target_memory.SetInst(pos, m_inst_set->GetRandomInst(ctx), false);
target_memory.SetFlagMutated(pos);
break;
case nMutation::TYPE_INSERT:
Modified: branches/interrupt/source/main/cGenome.cc
===================================================================
--- branches/interrupt/source/main/cGenome.cc 2008-08-05 16:18:59 UTC (rev 2742)
+++ branches/interrupt/source/main/cGenome.cc 2008-08-06 19:22:06 UTC (rev 2743)
@@ -32,6 +32,7 @@
cGenome::cGenome(int _size)
: genome(_size), protected_sites(_size), active_size(_size)
{
+ protected_sites.SetAll(false);
}
cGenome::cGenome(const cGenome & in_genome)
@@ -51,7 +52,7 @@
active_size = tmp_string.GetSize();
genome.ResizeClear(active_size);
protected_sites.ResizeClear(active_size);
- //protected_sites.SetAll(false);
+ protected_sites.SetAll(false);
for (int i = 0; i < active_size; i++) {
genome[i].SetSymbol(tmp_string[i]);
More information about the Avida-cvs
mailing list