[Avida-SVN] r3547 - in development/source: actions main
connel42 at myxo.css.msu.edu
connel42 at myxo.css.msu.edu
Mon Dec 7 07:18:55 PST 2009
Author: connel42
Date: 2009-12-07 10:18:55 -0500 (Mon, 07 Dec 2009)
New Revision: 3547
Modified:
development/source/actions/PopulationActions.cc
development/source/main/cStats.cc
development/source/main/cStats.h
Log:
Added additional output to orgs_killed data file and expanded kill event to include a kill density parameter
Modified: development/source/actions/PopulationActions.cc
===================================================================
--- development/source/actions/PopulationActions.cc 2009-12-05 17:58:06 UTC (rev 3546)
+++ development/source/actions/PopulationActions.cc 2009-12-07 15:18:55 UTC (rev 3547)
@@ -4013,6 +4013,7 @@
- The radius of the kill zone (default: 0)
- The name of the resource
- The amount of resource below which to execute the kill (default: 0)
+ - The fraction of orgs in the region to kill (1=all, 0.5 leave half) (default: 1) -- useful for controlling density with biofilms
*/
class cActionKillWithinRadiusBelowResourceThreshold : public cAction
@@ -4022,17 +4023,19 @@
int m_radius;
cString m_resname;
double m_threshold;
+ double m_kill_density;
public:
- cActionKillWithinRadiusBelowResourceThreshold(cWorld* world, const cString& args) : cAction(world, args), m_numradii(0), m_radius(0), m_threshold(0.0)
+ cActionKillWithinRadiusBelowResourceThreshold(cWorld* world, const cString& args) : cAction(world, args), m_numradii(0), m_radius(0), m_threshold(0.0), m_kill_density(1.0)
{
cString largs(args);
if (largs.GetSize()) m_numradii = largs.PopWord().AsInt();
if (largs.GetSize()) m_radius = largs.PopWord().AsInt();
if (largs.GetSize()) m_resname = largs.PopWord();
if (largs.GetSize()) m_threshold = largs.PopWord().AsDouble();
+ if (largs.GetSize()) m_kill_density = largs.PopWord().AsDouble();
}
- static const cString GetDescription() { return "Arguments: [int numradii=0, int radius=0, string resource name, double threshold=0]"; }
+ static const cString GetDescription() { return "Arguments: [int numradii=0, int radius=0, string resource name, double threshold=0, double killdensity=1]"; }
void Process(cAvidaContext& ctx)
{
@@ -4045,6 +4048,8 @@
assert(m_radius <= world_x);
assert(m_radius <= world_y);
assert(m_threshold >= 0.0);
+ assert(m_kill_density >= 0.0);
+ assert(m_kill_density <= 1.0);
assert(geometry == nGeometry::GRID || geometry == nGeometry::TORUS);
cPopulation& pop = m_world->GetPopulation();
@@ -4081,7 +4086,9 @@
int current_cell = (world_x * row_adj) + col_adj;
cPopulationCell& cell = pop.GetCell(current_cell);
- if (cell.IsOccupied()) {
+ m_world->GetStats().IncNumCellsScannedAtKill();
+
+ if( (cell.IsOccupied()) && (ctx.GetRandom().P(m_kill_density)) ) {
pop.KillOrganism(cell);
m_world->GetStats().IncNumOrgsKilled();
} else {
Modified: development/source/main/cStats.cc
===================================================================
--- development/source/main/cStats.cc 2009-12-05 17:58:06 UTC (rev 3546)
+++ development/source/main/cStats.cc 2009-12-07 15:18:55 UTC (rev 3547)
@@ -136,6 +136,7 @@
, m_spec_waste(0)
, num_orgs_killed(0)
, num_unoccupied_cell_kill_attempts(0)
+ , num_cells_scanned_at_kill(0)
, num_migrations(0)
, m_deme_num_repls(0)
, m_deme_num_repls_treatable(0)
@@ -581,6 +582,7 @@
num_orgs_killed = 0;
num_unoccupied_cell_kill_attempts = 0;
+ num_cells_scanned_at_kill = 0;
num_migrations = 0;
}
@@ -2483,6 +2485,7 @@
df.Write(m_update, "Update");
df.Write(num_orgs_killed, "Num Orgs Killed");
df.Write(num_unoccupied_cell_kill_attempts, "Num Unoccupied Cell Kill Attempts");
+ df.Write(num_cells_scanned_at_kill, "Num Cells Scanned By Kill Event");
df.Endl();
} //End PrintNumOrgsKilledData()
Modified: development/source/main/cStats.h
===================================================================
--- development/source/main/cStats.h 2009-12-05 17:58:06 UTC (rev 3546)
+++ development/source/main/cStats.h 2009-12-07 15:18:55 UTC (rev 3547)
@@ -343,6 +343,7 @@
// Number of organisms killed by kill actions
int num_orgs_killed;
int num_unoccupied_cell_kill_attempts;
+ int num_cells_scanned_at_kill;
// Number of migrations that have been made
int num_migrations;
@@ -577,6 +578,7 @@
void IncNumOrgsKilled() { num_orgs_killed++; }
void IncNumUnoccupiedCellAttemptedToKill() { num_unoccupied_cell_kill_attempts++; }
+ void IncNumCellsScannedAtKill() { num_cells_scanned_at_kill++; }
void IncNumMigrations() { num_migrations++; }
void AddCurTask(int task_num) { task_cur_count[task_num]++; }
@@ -753,6 +755,7 @@
int GetSpeculativeWaste() const { return m_spec_waste; }
int GetNumOrgsKilled() const { return num_orgs_killed; }
+ int GetNumCellsScannedAtKill() const { return num_cells_scanned_at_kill; }
int GetNumMigrations() const { return num_migrations; }
// this value gets recorded when a creature with the particular
More information about the Avida-cvs
mailing list