[Avida-SVN] r2674 - development/source/main
connel42 at myxo.css.msu.edu
connel42 at myxo.css.msu.edu
Mon Jun 23 09:48:54 PDT 2008
Author: connel42
Date: 2008-06-23 12:48:53 -0400 (Mon, 23 Jun 2008)
New Revision: 2674
Modified:
development/source/main/cResourceCount.cc
development/source/main/cSpatialCountElem.h
development/source/main/cSpatialResCount.cc
Log:
* Resources created with the CELL command are now included when resources are re-initialized
Modified: development/source/main/cResourceCount.cc
===================================================================
--- development/source/main/cResourceCount.cc 2008-06-22 23:55:25 UTC (rev 2673)
+++ development/source/main/cResourceCount.cc 2008-06-23 16:48:53 UTC (rev 2674)
@@ -493,7 +493,25 @@
}
void cResourceCount::ReinitializeResources(double additional_resource){
+ cSpatialResCount src;
+ double c_curr_amount;
+ double c_initial_amount;
+ double c_new_amount;
+
for(int i = 0; i < resource_name.GetSize(); i++) {
- Set(i, resource_initial[i]+additional_resource); //will cause problem if more than one resource is used.
- }
-}
+ Set(i, resource_initial[i]+additional_resource); //will cause problem if more than one resource is used. -- why? each resource is stored separately (BDC)
+
+ // Additionally, set any initial values given by the CELL command
+ src = GetSpatialResource(i);
+ for(int j = 0; j < src.GetSize(); j++) {
+ c_initial_amount = src.Element(j).GetInitial();
+ if(c_initial_amount > 0) {
+ c_curr_amount = spatial_resource_count[i].GetAmount(j);
+ c_new_amount = c_curr_amount + c_initial_amount + additional_resource;
+ spatial_resource_count[i].SetCellAmount(j, c_new_amount);
+ }
+ }
+
+ } //End going through the resources
+
+} //End ReinitializeResources()
Modified: development/source/main/cSpatialCountElem.h
===================================================================
--- development/source/main/cSpatialCountElem.h 2008-06-22 23:55:25 UTC (rev 2673)
+++ development/source/main/cSpatialCountElem.h 2008-06-23 16:48:53 UTC (rev 2674)
@@ -33,7 +33,7 @@
class cSpatialCountElem
{
private:
- mutable double amount, delta;
+ mutable double amount, delta, initial;
tArray<int> elempt, xdist, ydist;
tArray<double> dist;
@@ -52,6 +52,8 @@
double GetPtrDist(int innum) { return dist[innum]; }
friend void FlowMatter(cSpatialCountElem&, cSpatialCountElem&, double, double, double, double,
int, int, double);
+ void SetInitial(double init) { initial = init; }
+ double GetInitial() { return initial; }
};
Modified: development/source/main/cSpatialResCount.cc
===================================================================
--- development/source/main/cSpatialResCount.cc 2008-06-22 23:55:25 UTC (rev 2673)
+++ development/source/main/cSpatialResCount.cc 2008-06-23 16:48:53 UTC (rev 2674)
@@ -226,6 +226,7 @@
if (cell_id >= 0 && cell_id <= grid.GetSize()) {
Rate((*cell_list_ptr)[i].GetId(), (*cell_list_ptr)[i].GetInitial());
State((*cell_list_ptr)[i].GetId());
+ Element(cell_id).SetInitial((*cell_list_ptr)[i].GetInitial());
}
}
}
More information about the Avida-cvs
mailing list