[Avida-cvs] [avida-svn] r947 - in development/source: actions cpu main
ofria at myxo.css.msu.edu
ofria at myxo.css.msu.edu
Tue Sep 12 18:25:25 PDT 2006
Author: ofria
Date: 2006-09-12 21:25:25 -0400 (Tue, 12 Sep 2006)
New Revision: 947
Modified:
development/source/actions/PrintActions.cc
development/source/cpu/cHardwareCPU.cc
development/source/main/cPopulation.cc
Log:
Added a "print lineage grid" action/event.
Modified: development/source/actions/PrintActions.cc
===================================================================
--- development/source/actions/PrintActions.cc 2006-09-13 00:10:03 UTC (rev 946)
+++ development/source/actions/PrintActions.cc 2006-09-13 01:25:25 UTC (rev 947)
@@ -1000,7 +1000,7 @@
if (filename == "") filename.Set("tree_depth.%d.dat", m_world->GetStats().GetUpdate());
cDataFile& df = m_world->GetDataFile(filename);
- cPopulation& pop = m_world->GetPopulation();
+ // cPopulation& pop = m_world->GetPopulation();
cTestCPU* testcpu = m_world->GetHardwareManager().CreateTestCPU();
cGenotype* genotype = m_world->GetClassificationManager().GetBestGenotype();
@@ -1255,6 +1255,37 @@
};
+class cActionDumpLineageGrid : public cAction
+{
+private:
+ cString m_filename;
+
+public:
+ cActionDumpLineageGrid(cWorld* world, const cString& args) : cAction(world, args), m_filename("")
+ {
+ cString largs(args);
+ if (largs.GetSize()) m_filename = largs.PopWord();
+ }
+ static const cString GetDescription() { return "Arguments: [string fname='']"; }
+ void Process(cAvidaContext& ctx)
+ {
+ cString filename(m_filename);
+ if (filename == "") filename.Set("grid_lineage.%d.dat", m_world->GetStats().GetUpdate());
+ ofstream& fp = m_world->GetDataFileOFStream(filename);
+
+ for (int i = 0; i < m_world->GetPopulation().GetWorldX(); i++) {
+ for (int j = 0; j < m_world->GetPopulation().GetWorldY(); j++) {
+ cPopulationCell& cell = m_world->GetPopulation().GetCell(j * m_world->GetPopulation().GetWorldX() + i);
+ int id = (cell.IsOccupied()) ? cell.GetOrganism()->GetGenotype()->GetLineageLabel() : -1;
+ fp << id << " ";
+ }
+ fp << endl;
+ }
+ m_world->GetDataFileManager().Remove(filename);
+ }
+};
+
+
class cActionDumpTaskGrid : public cAction
{
private:
@@ -1477,6 +1508,7 @@
action_lib->Register<cActionDumpMemory>("DumpMemory");
action_lib->Register<cActionDumpFitnessGrid>("DumpFitnessGrid");
action_lib->Register<cActionDumpGenotypeIDGrid>("DumpGenotypeIDGrid");
+ action_lib->Register<cActionDumpLineageGrid>("DumpLineageGrid");
action_lib->Register<cActionDumpTaskGrid>("DumpTaskGrid");
action_lib->Register<cActionDumpDonorGrid>("DumpDonorGrid");
action_lib->Register<cActionDumpReceiverGrid>("DumpReceiverGrid");
@@ -1533,7 +1565,8 @@
action_lib->Register<cActionDumpMemory>("dump_memory");
action_lib->Register<cActionDumpFitnessGrid>("dump_fitness_grid");
- action_lib->Register<cActionDumpGenotypeIDGrid>("dump_enotype_grid");
+ action_lib->Register<cActionDumpGenotypeIDGrid>("dump_genotype_grid");
+ action_lib->Register<cActionDumpLineageGrid>("dump_lineage_grid");
action_lib->Register<cActionDumpTaskGrid>("dump_task_grid");
action_lib->Register<cActionDumpDonorGrid>("dump_donor_grid");
action_lib->Register<cActionDumpReceiverGrid>("dump_receiver_grid");
Modified: development/source/cpu/cHardwareCPU.cc
===================================================================
--- development/source/cpu/cHardwareCPU.cc 2006-09-13 00:10:03 UTC (rev 946)
+++ development/source/cpu/cHardwareCPU.cc 2006-09-13 01:25:25 UTC (rev 947)
@@ -2264,7 +2264,7 @@
{
const int reg_used = FindModifiedRegister(REG_AX);
double percentProb = ((double) (GetRegister(reg_used) % 100)) / 100.0;
- if ( ctx.GetRandom().P(percentProb) ) organism->Kaboom(0);
+ if ( ctx.GetRandom().P(percentProb) ) organism->Kaboom(5);
return true;
}
Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc 2006-09-13 00:10:03 UTC (rev 946)
+++ development/source/main/cPopulation.cc 2006-09-13 01:25:25 UTC (rev 947)
@@ -495,7 +495,7 @@
cGenome genome = genotype->GetGenome();
int id = genotype->GetID();
- int radius = 1;
+ int radius = 2;
int count = 0;
for (int i=-1*radius; i<=radius; i++) {
More information about the Avida-cvs
mailing list