MCPcopy Create free account
hub / github.com/devosoft/avida / ModifyCell

Method ModifyCell

avida-core/source/main/cResourceCount.cc:650–675  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

648}
649
650void cResourceCount::ModifyCell(cAvidaContext& ctx, const Apto::Array<double> & res_change, int cell_id)
651{
652 assert(resource_count.GetSize() == res_change.GetSize());
653
654 DoUpdates(ctx);
655 for (int i = 0; i < resource_count.GetSize(); i++) {
656 if (!IsSpatialResource(i)) {
657 resource_count[i] += res_change[i];
658 assert(resource_count[i] >= 0.0);
659 } else {
660 double temp = spatial_resource_count[i]->Element(cell_id).GetAmount();
661 spatial_resource_count[i]->Rate(cell_id, res_change[i]);
662 /* Ideally the state of the cell's resource should not be set till
663 the end of the update so that all processes (inflow, outflow,
664 diffision, gravity and organism demand) have the same weight. However
665 waiting can cause problems with negative resources so we allow
666 the organism demand to work immediately on the state of the resource */
667
668 spatial_resource_count[i]->State(cell_id);
669 if(spatial_resource_count[i]->Element(cell_id).GetAmount() != temp){
670 spatial_resource_count[i]->SetModified(true);
671 }
672 assert(spatial_resource_count[i]->Element(cell_id).GetAmount() >= 0.0);
673 }
674 }
675}
676
677double cResourceCount::Get(cAvidaContext& ctx, int res_id) const
678{

Callers 7

UpdateCellResourcesMethod · 0.80
ProcessUpdateMethod · 0.80
ModifyDemeResCountMethod · 0.80
GetAndClearCellEnergyMethod · 0.80
GiveBackCellEnergyMethod · 0.80
AddPheromoneMethod · 0.80
AdjustSpatialResourceMethod · 0.80

Calls 5

SetModifiedMethod · 0.80
GetSizeMethod · 0.45
GetAmountMethod · 0.45
RateMethod · 0.45
StateMethod · 0.45

Tested by

no test coverage detected