This tutorial will walk you through the steps involved in creating a deme replication event. It assumes that you have basic familiarity with C++ and Avida-ish stuff. There are several different deme replication events. Currently, they include events such as replicate when the deme is full, when the corners are occupied, when a set number of resources has been amassed (the consume-res event). For this tutorial, we'll be using 'consume-res' as an example. To add your new event:
DEME_TRIGGER_CONSUME_RESOURCES, // 10
Define your 'trigger' event as part of the Replicate Demes action. To do that, in PopulationActions.cc go to the class cActionReplicateDemes : public Action. Add the name of your trigger and a brief description to the comment:
'consume-res' ...demes that have consumed a sufficienct amount of resources
Then, add the same trigger to the end of the list of else if statements
else if (in_trigger == "consume-res") m_rep_trigger = DEME_TRIGGER_CONSUME_RESOURCES
Next, add the code that describes when your replication event will occur. In cPopulation.cc, locate the ReplicateDemes function:
void cPopulation::ReplicateDemes(int rep_trigger, cAvidaContext& ctx)
Within this function, add your new trigger both to the comments and to the switch statement. For example, for the 'consume-res' event the following line was added to the comment:
10:'consume-res' ...demes that have consumed a sufficienct amount of resources
case DEME_TRIGGER_CONSUME_RESOURCES: {
// check how many resources have been consumed by the deme
if (source_deme.GetTotalResourceAmountConsumed() <
m_world->GetConfig().RES_FOR_DEME_REP.Get()) {
continue;
}
Note that this code is using information about the deme. Clearly, if your method needs information from the deme and that information doesn't exist, you'll also need to write some code to do that...
u 1:1:end ReplicateDemes consume-res