[Avida-SVN] r2087 - branches/energy/source/main
beckma24 at myxo.css.msu.edu
beckma24 at myxo.css.msu.edu
Thu Sep 13 09:25:05 PDT 2007
Author: beckma24
Date: 2007-09-13 12:25:05 -0400 (Thu, 13 Sep 2007)
New Revision: 2087
Modified:
branches/energy/source/main/cPopulation.cc
Log:
Fixed bug in cPopulation:PositionChild. Deme birth counts where not being incremented in some BIRTH_METHODs.
Modified: branches/energy/source/main/cPopulation.cc
===================================================================
--- branches/energy/source/main/cPopulation.cc 2007-09-13 12:58:09 UTC (rev 2086)
+++ branches/energy/source/main/cPopulation.cc 2007-09-13 16:25:05 UTC (rev 2087)
@@ -1947,7 +1947,10 @@
while (parent_ok == false && out_pos == parent_cell.GetID()) {
out_pos = m_world->GetRandom().GetUInt(cell_array.GetSize());
}
- return GetCell(out_pos);
+ cPopulationCell& out_cell = GetCell(out_pos);
+ const int deme_id = out_cell.GetDemeID();
+ deme_array[deme_id].IncBirthCount();
+ return out_cell;
}
else if (birth_method == POSITION_CHILD_FULL_SOUP_ELDEST) {
cPopulationCell * out_cell = reaper_queue.PopRear();
@@ -1955,6 +1958,8 @@
out_cell = reaper_queue.PopRear();
reaper_queue.PushRear(&parent_cell);
}
+ const int deme_id = out_cell->GetDemeID();
+ deme_array[deme_id].IncBirthCount();
return *out_cell;
}
else if (birth_method == POSITION_CHILD_DEME_RANDOM) {
@@ -1972,12 +1977,17 @@
return GetCell(out_cell_id);
}
else if (birth_method == POSITION_CHILD_PARENT_FACING) {
+ const int deme_id = parent_cell.GetDemeID();
+ deme_array[deme_id].IncBirthCount();
return parent_cell.GetCellFaced();
}
else if (birth_method == POSITION_CHILD_NEXT_CELL) {
int out_cell_id = parent_cell.GetID() + 1;
if (out_cell_id == cell_array.GetSize()) out_cell_id = 0;
- return GetCell(out_cell_id);
+ cPopulationCell& out_cell = GetCell(out_cell_id);
+ const int deme_id = out_cell.GetDemeID();
+ deme_array[deme_id].IncBirthCount();
+ return out_cell;
}
else if (birth_method == POSITION_CHILD_FULL_SOUP_ENERGY_USED) {
tList<cPopulationCell> found_list;
@@ -1997,7 +2007,10 @@
}
}
int choice = m_world->GetRandom().GetUInt(found_list.GetSize());
- return *( found_list.GetPos(choice) );
+ cPopulationCell* out_cell = found_list.GetPos(choice);
+ const int deme_id = out_cell->GetDemeID();
+ deme_array[deme_id].IncBirthCount();
+ return *( out_cell );
}
// All remaining methods require us to choose among mulitple local positions.
More information about the Avida-cvs
mailing list