[Avida-SVN] r3270 - in branches/interrupt/source: actions cpu main
beckma24 at myxo.css.msu.edu
beckma24 at myxo.css.msu.edu
Sat May 30 09:03:46 PDT 2009
Author: beckma24
Date: 2009-05-30 12:03:46 -0400 (Sat, 30 May 2009)
New Revision: 3270
Modified:
branches/interrupt/source/actions/PrintActions.cc
branches/interrupt/source/cpu/cHardwareCPU.cc
branches/interrupt/source/cpu/cHardwareCPU.h
branches/interrupt/source/main/cAvidaConfig.h
branches/interrupt/source/main/cAvidaContext.h
branches/interrupt/source/main/cDeme.cc
branches/interrupt/source/main/cDeme.h
branches/interrupt/source/main/cPopulation.cc
branches/interrupt/source/main/cPopulation.h
branches/interrupt/source/main/cPopulationCell.cc
branches/interrupt/source/main/cPopulationCell.h
branches/interrupt/source/main/cPopulationInterface.cc
branches/interrupt/source/main/nGeometry.h
Log:
Initial boundary defined signaling code
Modified: branches/interrupt/source/actions/PrintActions.cc
===================================================================
--- branches/interrupt/source/actions/PrintActions.cc 2009-05-29 15:13:02 UTC (rev 3269)
+++ branches/interrupt/source/actions/PrintActions.cc 2009-05-30 16:03:46 UTC (rev 3270)
@@ -149,6 +149,7 @@
POP_OUT_FILE(PrintPhenotypeData, phenotype_count.dat );
POP_OUT_FILE(PrintPhenotypeStatus, phenotype_status.dat);
POP_OUT_FILE(PrintDemeTestamentStats, deme_testament.dat );
+POP_OUT_FILE(DumpDemeBoundaryData, deme_boundary ); // file name is dummy
class cActionPrintData : public cAction
@@ -2817,7 +2818,7 @@
action_lib->Register<cActionPrintDemeInterruptMsgType>("PrintDemeInterruptMsgType");
action_lib->Register<cActionDumpInterruptGrid>("DumpInterruptGrid");
action_lib->Register<cActionPrintWithinDemeGeneticDistance>("PrintWithinDemeGeneticDistance");
-
+ action_lib->Register<cActionDumpDemeBoundaryData>("DumpDemeBoundaryData");
//Coalescence Clade Actions
action_lib->Register<cActionPrintCCladeCounts>("PrintCCladeCounts");
Modified: branches/interrupt/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/interrupt/source/cpu/cHardwareCPU.cc 2009-05-29 15:13:02 UTC (rev 3269)
+++ branches/interrupt/source/cpu/cHardwareCPU.cc 2009-05-30 16:03:46 UTC (rev 3270)
@@ -549,7 +549,9 @@
tInstLibEntry<tMethod>("h-divide0.001", &cHardwareCPU::Inst_HeadDivide0_001, nInstFlag::STALL),
// High-level instructions
- tInstLibEntry<tMethod>("repro_deme", &cHardwareCPU::Inst_ReproDeme, nInstFlag::STALL),
+ tInstLibEntry<tMethod>("repro-newInnerBoundary", &cHardwareCPU::Inst_Repro_NewInnerBoundary, nInstFlag::STALL),
+ tInstLibEntry<tMethod>("repro-inParentBoundary", &cHardwareCPU::Inst_Repro_InParentBoundary, nInstFlag::STALL),
+ tInstLibEntry<tMethod>("repro-deme", &cHardwareCPU::Inst_ReproDeme, nInstFlag::STALL),
tInstLibEntry<tMethod>("repro", &cHardwareCPU::Inst_Repro, nInstFlag::STALL),
tInstLibEntry<tMethod>("repro-sex", &cHardwareCPU::Inst_ReproSex, nInstFlag::STALL),
tInstLibEntry<tMethod>("repro-A", &cHardwareCPU::Inst_Repro, nInstFlag::STALL),
@@ -2912,6 +2914,115 @@
return true;
}
+bool cHardwareCPU::Inst_Repro_NewInnerBoundary(cAvidaContext& ctx) {
+// // check if repro can replace an existing organism
+// if(m_world->GetConfig().REPRO_METHOD.Get() == 0 && m_organism->IsNeighborCellOccupied())
+// return false;
+
+ if (m_organism->GetPhenotype().GetCurBonus() < m_world->GetConfig().REQUIRED_BONUS.Get()) return false;
+
+ // Setup child
+ cCPUMemory& child_genome = m_organism->ChildGenome();
+ child_genome = m_organism->GetGenome();
+
+ // Do transposon movement and copying before other mutations
+ Divide_DoTransposons(ctx);
+
+ // Perform Copy Mutations...
+ if (m_organism->GetCopyMutProb() > 0) { // Skip this if no mutations....
+ for (int i = 0; i < m_memory.GetSize(); i++) {
+ if (m_organism->TestCopyMut(ctx)) {
+ child_genome.SetInst(i, m_inst_set->GetRandomInst(ctx), false);
+ }
+ }
+ }
+
+ Divide_DoMutations(ctx);
+
+ // Check viability
+ bool viable = Divide_CheckViable(ctx, m_organism->GetGenome().GetSize(), m_organism->ChildGenome().GetSize(), 1);
+ if (!viable) { return false; }
+
+ // Many tests will require us to run the offspring through a test CPU;
+ // this is, for example, to see if mutations need to be reverted or if
+ // lineages need to be updated.
+ Divide_TestFitnessMeasures(ctx);
+
+#if INSTRUCTION_COSTS
+ // reset first time instruction costs
+ for (int i = 0; i < m_inst_ft_cost.GetSize(); i++) {
+ m_inst_ft_cost[i] = m_inst_set->GetFTCost(cInstruction(i));
+ }
+#endif
+
+ if (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) m_advance_ip = false;
+
+ ctx.setExtraData("Repro-NewInnerBoundary");
+ const bool parent_alive = m_organism->ActivateDivide(ctx);
+ ctx.clearExtraData();
+
+ //Reset the parent
+ if (parent_alive) {
+ if (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) Reset(ctx);
+ }
+ return true;
+}
+
+bool cHardwareCPU::Inst_Repro_InParentBoundary(cAvidaContext& ctx) {
+// // check if repro can replace an existing organism
+// if(m_world->GetConfig().REPRO_METHOD.Get() == 0 && m_organism->IsNeighborCellOccupied())
+// return false;
+
+ if (m_organism->GetPhenotype().GetCurBonus() < m_world->GetConfig().REQUIRED_BONUS.Get()) return false;
+
+ // Setup child
+ cCPUMemory& child_genome = m_organism->ChildGenome();
+ child_genome = m_organism->GetGenome();
+
+ // Do transposon movement and copying before other mutations
+ Divide_DoTransposons(ctx);
+
+ // Perform Copy Mutations...
+ if (m_organism->GetCopyMutProb() > 0) { // Skip this if no mutations....
+ for (int i = 0; i < m_memory.GetSize(); i++) {
+ if (m_organism->TestCopyMut(ctx)) {
+ child_genome.SetInst(i, m_inst_set->GetRandomInst(ctx), false);
+ }
+ }
+ }
+
+ Divide_DoMutations(ctx);
+
+ // Check viability
+ bool viable = Divide_CheckViable(ctx, m_organism->GetGenome().GetSize(), m_organism->ChildGenome().GetSize(), 1);
+ if (!viable) { return false; }
+
+ // Many tests will require us to run the offspring through a test CPU;
+ // this is, for example, to see if mutations need to be reverted or if
+ // lineages need to be updated.
+ Divide_TestFitnessMeasures(ctx);
+
+#if INSTRUCTION_COSTS
+ // reset first time instruction costs
+ for (int i = 0; i < m_inst_ft_cost.GetSize(); i++) {
+ m_inst_ft_cost[i] = m_inst_set->GetFTCost(cInstruction(i));
+ }
+#endif
+
+ if (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) m_advance_ip = false;
+
+ ctx.setExtraData("Repro-InParentBoundary");
+ const bool parent_alive = m_organism->ActivateDivide(ctx);
+ ctx.clearExtraData();
+
+ //Reset the parent
+ if (parent_alive) {
+ if (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) Reset(ctx);
+ }
+ return true;
+}
+
+
bool cHardwareCPU::Inst_Repro(cAvidaContext& ctx)
{
// check if repro can replace an existing organism
Modified: branches/interrupt/source/cpu/cHardwareCPU.h
===================================================================
--- branches/interrupt/source/cpu/cHardwareCPU.h 2009-05-29 15:13:02 UTC (rev 3269)
+++ branches/interrupt/source/cpu/cHardwareCPU.h 2009-05-30 16:03:46 UTC (rev 3270)
@@ -472,6 +472,8 @@
bool Inst_InjectThread(cAvidaContext& ctx);
bool Inst_Transposon(cAvidaContext& ctx);
bool Inst_ReproDeme(cAvidaContext& ctx);
+ bool Inst_Repro_NewInnerBoundary(cAvidaContext& ctx);
+ bool Inst_Repro_InParentBoundary(cAvidaContext& ctx);
bool Inst_Repro(cAvidaContext& ctx);
bool Inst_ReproSex(cAvidaContext& ctx);
bool Inst_TaskPutRepro(cAvidaContext& ctx);
Modified: branches/interrupt/source/main/cAvidaConfig.h
===================================================================
--- branches/interrupt/source/main/cAvidaConfig.h 2009-05-29 15:13:02 UTC (rev 3269)
+++ branches/interrupt/source/main/cAvidaConfig.h 2009-05-30 16:03:46 UTC (rev 3270)
@@ -281,7 +281,7 @@
CONFIG_ADD_VAR(WORLD_X, int, 60, "Width of the Avida world");
CONFIG_ADD_VAR(WORLD_Y, int, 60, "Height of the Avida world");
CONFIG_ADD_VAR(WORLD_Z, int, 1, "Depth of the Avida world");
- CONFIG_ADD_VAR(WORLD_GEOMETRY, int, 2, "1 = Bounded Grid\n2 = Torus\n3 = Clique\n4 = Hexagonal grid\n5 = Lattice");
+ CONFIG_ADD_VAR(WORLD_GEOMETRY, int, 2, "1 = Bounded Grid\n2 = Torus\n3 = Clique\n4 = Hexagonal grid\n5 = Lattice\n7 = None\n");
CONFIG_ADD_VAR(RANDOM_SEED, int, 0, "Random number seed (0 for based on time)");
CONFIG_ADD_VAR(HARDWARE_TYPE, int, 0, "0 = Original CPUs\n1 = New SMT CPUs\n2 = Transitional SMT\n3 = Experimental CPU\n4 = Gene Expression CPU");
CONFIG_ADD_VAR(SPECULATIVE, bool, 1, "Enable speculative execution");
Modified: branches/interrupt/source/main/cAvidaContext.h
===================================================================
--- branches/interrupt/source/main/cAvidaContext.h 2009-05-29 15:13:02 UTC (rev 3269)
+++ branches/interrupt/source/main/cAvidaContext.h 2009-05-30 16:03:46 UTC (rev 3270)
@@ -34,8 +34,8 @@
# include "tMemTrack.h"
# endif
#endif
+#include "cString.h"
-
class cRandom;
class cAvidaContext
@@ -46,10 +46,11 @@
private:
cRandom* m_rng;
bool m_analyze;
+ cString extraData;
public:
- cAvidaContext(cRandom& rng) : m_rng(&rng), m_analyze(false) { ; }
- cAvidaContext(cRandom* rng) : m_rng(rng), m_analyze(false) { ; }
+ cAvidaContext(cRandom& rng) : m_rng(&rng), m_analyze(false), extraData("") { ; }
+ cAvidaContext(cRandom* rng) : m_rng(rng), m_analyze(false), extraData("") { ; }
~cAvidaContext() { ; }
void SetRandom(cRandom& rng) { m_rng = &rng; }
@@ -59,6 +60,11 @@
void SetAnalyzeMode() { m_analyze = true; }
void ClearAnalyzeMode() { m_analyze = false; }
bool GetAnalyzeMode() { return m_analyze; }
+
+ void setExtraData(const cString str) { assert(extraData==""); extraData = str; } // must clear data before setting
+ void clearExtraData() { extraData = ""; }
+ cString getExtraData() const { return extraData; }
+
};
#endif
Modified: branches/interrupt/source/main/cDeme.cc
===================================================================
--- branches/interrupt/source/main/cDeme.cc 2009-05-29 15:13:02 UTC (rev 3269)
+++ branches/interrupt/source/main/cDeme.cc 2009-05-30 16:03:46 UTC (rev 3270)
@@ -271,6 +271,16 @@
(*movement_pred_list[i]).Reset();
}
+ static const int geometry = m_world->GetConfig().WORLD_GEOMETRY.Get();
+ if(geometry == nGeometry::NONE) {
+ for(int i = 0; i < GetSize(); ++i) {
+ cPopulationCell& cell = GetCell(i);
+ cell.ConnectionList().Clear();
+ cell.setBoundary(0);
+ nextAvailBoundary = 0;
+ }
+ }
+
if (resetResources) {
deme_resource_count.ReinitializeResources(additional_resource);
}
@@ -824,6 +834,7 @@
//Note: this code currently supports a grid or torus
assert(geometry == nGeometry::GRID || geometry == nGeometry::TORUS);
+ // TODO: make more general, use connection list
if(geometry == nGeometry::GRID) {
for(int y = curr_y - radius; y <= curr_y + radius; y++) {
Modified: branches/interrupt/source/main/cDeme.h
===================================================================
--- branches/interrupt/source/main/cDeme.h 2009-05-29 15:13:02 UTC (rev 3269)
+++ branches/interrupt/source/main/cDeme.h 2009-05-30 16:03:46 UTC (rev 3270)
@@ -87,6 +87,7 @@
unsigned int consecutiveSuccessfulEventPeriods;
int sleeping_count; //!< Number of organisms currently sleeping
cDoubleSum energyUsage;
+ int nextAvailBoundary;
tArray<int> cur_task_exe_count;
tArray<int> cur_reaction_count;
@@ -137,9 +138,10 @@
cDeme() : _id(0), width(0), replicateDeme(false), cur_birth_count(0), last_birth_count(0), cur_org_count(0), last_org_count(0), injected_count(0), birth_count_perslot(0),
_age(0), generation(0), total_org_energy(0.0),
time_used(0), gestation_time(0), cur_normalized_time_used(0.0), last_normalized_time_used(0.0),
- MSG_sendFailed(0), MSG_dropped(0), MSG_SuccessfullySent(0), MSG_sent(0), energyInjectedIntoOrganisms(0.0), energyRemainingInDemeAtReplication(0.0), total_energy_testament(0.0),
+ MSG_sendFailed(0), MSG_dropped(0), MSG_SuccessfullySent(0), MSG_sent(0),
+ energyInjectedIntoOrganisms(0.0), energyRemainingInDemeAtReplication(0.0), total_energy_testament(0.0),
eventsTotal(0), eventsKilled(0), eventsKilledThisSlot(0), eventKillAttempts(0), eventKillAttemptsThisSlot(0),
- consecutiveSuccessfulEventPeriods(0), sleeping_count(0),
+ consecutiveSuccessfulEventPeriods(0), sleeping_count(0), nextAvailBoundary(0),
avg_founder_generation(0.0), generations_per_lifetime(0.0),
deme_resource_count(0), m_germline_genotype_id(0), points(0), migrations_out(0), migrations_in(0), suicides(0){ ; }
~cDeme() { ; }
@@ -340,6 +342,11 @@
bool allOrgsHaveSetOpinion();
void GetSurroundingCellIds(tVector<int> &cells, const int absolute_cell_id, const int radius);
+
+ // ----Boundaries---//
+ int getThenIncNextAvailBoundary() { return nextAvailBoundary++; }
+ int getNextAvailBoundary() const { return nextAvailBoundary; }
+
};
#endif
Modified: branches/interrupt/source/main/cPopulation.cc
===================================================================
--- branches/interrupt/source/main/cPopulation.cc 2009-05-29 15:13:02 UTC (rev 3269)
+++ branches/interrupt/source/main/cPopulation.cc 2009-05-30 16:03:46 UTC (rev 3270)
@@ -45,6 +45,7 @@
#include "cInstSet.h"
#include "cIntegratedSchedule.h"
#include "cLineage.h"
+#include "tList.h"
#include "cOrganism.h"
#include "cPhenotype.h"
#include "cPopulationCell.h"
@@ -112,8 +113,9 @@
case nGeometry::TORUS: { cout << "Geometry: Torus" << endl; break; }
case nGeometry::CLIQUE: { cout << "Geometry: Clique" << endl; break; }
case nGeometry::HEX: { cout << "Geometry: Hex" << endl; break; }
- case nGeometry::LATTICE: { cout << "Geometry: Lattice" << endl; break; }
- case nGeometry::PARTIAL: { cout << "Geometry: Partial" << endl; break; }
+ case nGeometry::LATTICE: { cout << "Geometry: Lattice" << endl; break; }
+ case nGeometry::PARTIAL: { cout << "Geometry: Partial" << endl; break; }
+ case nGeometry::NONE: { cout << "Geometry: None" << endl; break; }
default:
cout << "Unknown geometry!" << endl;
assert(false);
@@ -207,6 +209,9 @@
case nGeometry::LATTICE:
build_lattice(&cell_array.begin()[i], &cell_array.begin()[i+deme_size], deme_size_x, deme_size_y, world_z);
break;
+ case nGeometry::NONE:
+ // TODO: check for geometry dependent things
+ break;
default:
assert(false);
}
@@ -429,9 +434,78 @@
// Place all of the offspring...
+ const cString initiatingInst = ctx.getExtraData();
+
for (int i = 0; i < child_array.GetSize(); i++) {
- ActivateOrganism(ctx, child_array[i], GetCell(target_cells[i]));
-
+ cPopulationCell& targetCell = GetCell(target_cells[i]);
+ ActivateOrganism(ctx, child_array[i], targetCell);
+ cDeme& deme = GetDeme(targetCell.GetDemeID());
+
+ if(initiatingInst != "") {
+ if(initiatingInst == "Repro-InParentBoundary") {
+ //Set target cell's boundary to parentCellBoundary
+ const int parentCellBoundary = parent_cell.getBoundary();
+ targetCell.setBoundary(parentCellBoundary);
+
+ tList<cPopulationCell>& targetCellConnectionList = targetCell.ConnectionList();
+ tList<cPopulationCell>& parentCellConnectionList = parent_cell.ConnectionList();
+
+ //remove target from all connection lists that point to it, restriced to within deme
+ for(int cellIndex = 0; cellIndex < deme.GetSize(); ++cellIndex) {
+ GetCell(deme.GetCellID(cellIndex)).ConnectionList().Remove(&targetCell);
+ }
+
+ // clear target cell connection list
+ targetCellConnectionList.Clear();
+ // target is now isolated
+
+ // add parent cell to target's connection list
+ targetCellConnectionList.Push(&parent_cell);
+ // append parent's connection list to target's connection list
+ targetCellConnectionList.Append(parentCellConnectionList);
+
+ // connect to the target everything the target is connected to
+ for(int cellIndex = 0; cellIndex < targetCellConnectionList.GetSize(); ++cellIndex) {
+ targetCellConnectionList.GetPos(cellIndex)->ConnectionList().Push(&targetCell);
+ }
+
+ } else if(initiatingInst == "Repro-NewInnerBoundary") {
+ //Set target cell's boundary to next available
+ const int nextAvailDemeBoundary = GetDeme(parent_cell.GetDemeID()).getThenIncNextAvailBoundary();
+ targetCell.setBoundary(nextAvailDemeBoundary);
+
+ tList<cPopulationCell>& targetCellConnectionList = targetCell.ConnectionList();
+ tList<cPopulationCell>& parentCellConnectionList = parent_cell.ConnectionList();
+
+ //remove target from all connection lists that point to it, restriced to within deme
+ for(int cellIndex = 0; cellIndex < deme.GetSize(); ++cellIndex) {
+ GetCell(deme.GetCellID(cellIndex)).ConnectionList().Remove(&targetCell);
+ }
+
+ // clear target cell connection list
+ targetCellConnectionList.Clear();
+ // target is now isolated
+
+ // add parent cell to target's connection list
+ targetCellConnectionList.Push(&parent_cell);
+
+ // connect cell in parent's connection list that are at parent's boundary
+ for(int cellIndex = 0; cellIndex < parentCellConnectionList.GetSize(); ++cellIndex) {
+ cPopulationCell* cell = parentCellConnectionList.GetPos(cellIndex);
+ if(cell->getBoundary() == parent_cell.getBoundary()) {
+ targetCellConnectionList.Push(cell);
+ }
+ }
+
+ // connect to the target everything the target is connected to
+ for(int cellIndex = 0; cellIndex < targetCellConnectionList.GetSize(); ++cellIndex) {
+ targetCellConnectionList.GetPos(cellIndex)->ConnectionList().Push(&targetCell);
+ }
+ } else {
+ assert(false); //unknown initiatingInst
+ }
+ }
+
//@JEB - we may want to pass along some state information from parent to child
if ( (m_world->GetConfig().EPIGENETIC_METHOD.Get() == EPIGENETIC_METHOD_OFFSPRING)
|| (m_world->GetConfig().EPIGENETIC_METHOD.Get() == EPIGENETIC_METHOD_BOTH) ) {
@@ -2647,6 +2721,40 @@
stats.SumEnergyTestamentToNeighborOrganisms().Clear();
}
+void cPopulation::DumpDemeBoundaryData(const cString& filename) {
+ cString m_filename;
+ m_filename.Set("deme_boundary.%d.dat", m_world->GetStats().GetUpdate());
+ cDataFile& df = m_world->GetDataFile(m_filename);
+
+ for(int i = 0; i < GetNumDemes(); ++i) {
+ cDeme& deme = GetDeme(i);
+ int currentBoundary = -1; // start here as a check; if any have bourdary of -1 we have a problem
+ const int nextAvailableBoundary = deme.getNextAvailBoundary();
+
+ while (currentBoundary <= nextAvailableBoundary) {
+ // TODO: search all cells in deme and print those with boundary equal to currentBoundary
+ for(int cellID = 0; cellID < deme.GetSize(); ++cellID) {
+ cPopulationCell& cell = deme.GetCell(cellID);
+ if(cell.getBoundary() == currentBoundary) {
+ df.Write(cellID, "cellID");
+ df.Write(currentBoundary, "boundary");
+ tList<cPopulationCell>& connectionList = cell.ConnectionList();
+ for(int listItem = 0; listItem < connectionList.GetSize(); ++listItem) {
+ for(int k = 0; k < deme.GetSize(); ++k) {
+ if(deme.GetAbsoluteCellID(k) == connectionList.GetPos(listItem)->GetID())
+ df.WriteBlockElement(k, listItem, connectionList.GetSize());
+ }
+ }
+ df.Endl();
+ }
+ }
+ ++currentBoundary;
+ }
+ df.Endl();
+ df.Endl();
+ }
+ m_world->GetDataFileManager().Remove(m_filename);
+}
// Print some stats about the energy sharing behavior of each deme
void cPopulation::PrintDemeEnergySharingStats() {
@@ -4457,6 +4565,8 @@
cGenotype * genotype = m_world->GetClassificationManager().FindGenotype(genome, lineage_label);
deme.ReplaceGermline(*genotype);
}
+ // TODO: fix. every injected org is in boundary 0
+ GetCell(cell_id).setBoundary(deme_array[GetCell(cell_id).GetDemeID()].getThenIncNextAvailBoundary());
}
void cPopulation::InjectParasite(const cCodeLabel& label, const cGenome& injected_code, int cell_id)
Modified: branches/interrupt/source/main/cPopulation.h
===================================================================
--- branches/interrupt/source/main/cPopulation.h 2009-05-29 15:13:02 UTC (rev 3269)
+++ branches/interrupt/source/main/cPopulation.h 2009-05-30 16:03:46 UTC (rev 3270)
@@ -248,6 +248,7 @@
void PrintDemeTasks();
void PrintDemeTotalAvgEnergy();
void PrintWithinDemeGeneticDistance() const;
+ void DumpDemeBoundaryData(const cString& filename);
// Print deme founders
void DumpDemeFounders(ofstream& fp);
Modified: branches/interrupt/source/main/cPopulationCell.cc
===================================================================
--- branches/interrupt/source/main/cPopulationCell.cc 2009-05-29 15:13:02 UTC (rev 3269)
+++ branches/interrupt/source/main/cPopulationCell.cc 2009-05-30 16:03:46 UTC (rev 3270)
@@ -46,6 +46,7 @@
, m_deme_id(in_cell.m_deme_id)
, m_cell_data(in_cell.m_cell_data)
, m_spec_state(in_cell.m_spec_state)
+ , m_boundary(in_cell.m_boundary)
{
// Copy the mutation rates into a new structure
m_mut_rates = new cMutationRates(*in_cell.m_mut_rates);
@@ -66,6 +67,7 @@
m_deme_id = in_cell.m_deme_id;
m_cell_data = in_cell.m_cell_data;
m_spec_state = in_cell.m_spec_state;
+ m_boundary = in_cell.m_boundary;
// Copy the mutation rates, constructing the structure as necessary
if (m_mut_rates == NULL)
@@ -88,6 +90,7 @@
m_deme_id = -1;
m_cell_data = 0;
m_spec_state = 0;
+ m_boundary = -1;
if (m_mut_rates == NULL)
m_mut_rates = new cMutationRates(in_rates);
@@ -190,7 +193,7 @@
if(m_organism->GetOrgInterface().GetPrevSeenCellID() == -1) {
m_organism->GetOrgInterface().SetPrevSeenCellID(m_cell_id);
}
-
+
if(m_world->GetConfig().ENERGY_ENABLED.Get() == 1 && m_world->GetConfig().FRAC_ENERGY_TRANSFER.Get() > 0.0) {
// uptake all the cells energy
double uptake_energy = UptakeCellEnergy(1.0);
Modified: branches/interrupt/source/main/cPopulationCell.h
===================================================================
--- branches/interrupt/source/main/cPopulationCell.h 2009-05-29 15:13:02 UTC (rev 3269)
+++ branches/interrupt/source/main/cPopulationCell.h 2009-05-30 16:03:46 UTC (rev 3270)
@@ -62,6 +62,7 @@
int m_deme_id; // ID of the deme that this cell is part of.
int m_cell_data; // "data" that is local to the cell and can be retrieaved by the org.
int m_spec_state;
+ int m_boundary;
bool m_migrant; //@AWC -- does the cell contain a migrant genome?
@@ -77,7 +78,7 @@
public:
- cPopulationCell() : m_world(NULL), m_organism(NULL), m_hardware(NULL), m_mut_rates(NULL), m_migrant(false) { ; }
+ cPopulationCell() : m_world(NULL), m_organism(NULL), m_hardware(NULL), m_mut_rates(NULL), m_boundary(-1), m_migrant(false) { ; }
cPopulationCell(const cPopulationCell& in_cell);
~cPopulationCell() { delete m_mut_rates; }
@@ -121,6 +122,9 @@
inline bool IsOccupied() const { return m_organism != NULL; }
double UptakeCellEnergy(double frac_to_uptake);
+
+ int getBoundary() const { return m_boundary; }
+ void setBoundary(int boundary) { m_boundary = boundary; }
bool OK();
};
Modified: branches/interrupt/source/main/cPopulationInterface.cc
===================================================================
--- branches/interrupt/source/main/cPopulationInterface.cc 2009-05-29 15:13:02 UTC (rev 3269)
+++ branches/interrupt/source/main/cPopulationInterface.cc 2009-05-30 16:03:46 UTC (rev 3270)
@@ -276,7 +276,10 @@
cPopulationCell& cell = m_world->GetPopulation().GetCell(m_cell_id);
assert(cell.IsOccupied()); // This organism; sanity.
cPopulationCell* rcell = cell.ConnectionList().GetFirst();
- assert(rcell != NULL); // Cells should never be null.
+ if(rcell == NULL) {
+ GetDeme()->messageDropped();
+ return true;
+ }
// Fail if the cell we're facing is not occupied.
if(!rcell->IsOccupied())
Modified: branches/interrupt/source/main/nGeometry.h
===================================================================
--- branches/interrupt/source/main/nGeometry.h 2009-05-29 15:13:02 UTC (rev 3269)
+++ branches/interrupt/source/main/nGeometry.h 2009-05-30 16:03:46 UTC (rev 3270)
@@ -34,8 +34,9 @@
TORUS,
CLIQUE,
HEX,
- PARTIAL,
- LATTICE
+ PARTIAL,
+ LATTICE,
+ NONE
};
}
More information about the Avida-cvs
mailing list