Exemplo n.º 1
0
void EnvironmentCA2DMulti::update()
{
    Environment::update();
    
    if (settings.payoff_depletion_rate_arg)
    {
        for (agent_iterator it = mAgents.begin(); it != mAgents.end(); ++it)
        {
            Agent *agent = *it;
            int index = agent->get_index();
            Point2Di position = this->mPositions[index];
            this->mLandscape->deplete_at(position.x, position.y);
        }
    }

    this->mLandscape->regenerate();
}
Exemplo n.º 2
0
void EnvironmentGraph::reproduce()
{
	/*--------------------------------------------------------------------*
	 * birth-death reproduction
	 *--------------------------------------------------------------------*/
	int parent_index = this->select_parent();
	Agent *parent = mAgents[parent_index];
	Agent *child = parent->replicate();

	vector <Agent *> neighbours = this->get_neighbours(parent);
	Agent *neighbour = neighbours[rng_randint(0, neighbours.size())];
	int child_index = neighbour->get_index();

	delete mAgents[child_index];
	mAgents[child_index] = child;
	mGraph->mNodes[child_index]->mData = child;
}