本文整理汇总了C++中Agent::addSpecialAgent方法的典型用法代码示例。如果您正苦于以下问题:C++ Agent::addSpecialAgent方法的具体用法?C++ Agent::addSpecialAgent怎么用?C++ Agent::addSpecialAgent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Agent
的用法示例。
在下文中一共展示了Agent::addSpecialAgent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setupAgentHierarchy
void ChemoPopComposer::setupAgentHierarchy() {
// set children of maestro
if (this->number_of_cells > 0) {
for (int i=1;i<=this->number_of_cells; i++) {
Agent *cell = orchestra.at(i);
maestro->addChild(cell->getAgentId());
cell->setParent(maestro->getAgentId());
cell->addSpecialAgent(this->special_agents[0]->getAgentId());
}
}
maestro->addSpecialAgent(this->special_agents[0]->getAgentId());
}
示例2: placeMessage
void BlindAgentNotifyWorldThatNewAgentIsBorn::placeMessage(int destID) {
//check if I have to give birth or not
if(birthFlag->getBool())
{
birthFlag->setBool(false);
// if the death simulator determined death, then do not create the birth message
if(deathFlag->getBool()) return;
//get the agentfactory, and use it to create an agent
AgentFactory *af = Registrar::getSystemRegistrar()->getAgentFactory(1);
Agent *a = af->createAgent();
// has the same parent
// NOTE: the parent is the top level agent in the hierarchy of agents,
// not the agent that gave birth!
a->setParent(source->getParentId());
// has the same special agents
for(unsigned int s=0; s<source->getNumOfSpecialAgents(); s++)
a->addSpecialAgent(source->getSpecialAgentId(s));
// needs the same communicator, of course, of course
a->addCommunicator(source->getCommunicator());
// set the other properties of agent 'a' based on the source exactly...
a->copyDatabaseInformationFromExistingAgent(this->source);
// CLEARLY A HACK!! CHANGE THIS AT SOME POINT TO DUPLICATE SIMULATORS
// replace the movement simulator with the correct one
if (((BoolData*) a->getDatabase()->getDataItem("is_levy"))->getBool()) {
LevyRunLengthSimulator *levy = new LevyRunLengthSimulator();
a->replaceSimulator(0,levy);
} else {
ExponentialRunLengthSimulator *expo = new ExponentialRunLengthSimulator();
a->replaceSimulator(0,expo);
}
// ANOTHER HACK !! TIME TO NEXT OUTPUT IS OFF WHEN WE GET HERE, SO WE MUST UPDATE
DoubleData *t = (DoubleData *) a->getDatabase()->getDataItem("celltime");
//DoubleData *oi = (DoubleData *) a->getDatabase()->getDataItem("outputinterval");
//DoubleData *no = (DoubleData*) a->getDatabase()->getDataItem("nextOutputTime");
DoubleData *dt = (DoubleData *) a->getDatabase()->getDataItem("dt");
t->setDouble(t->getDouble()-dt->getDouble());
//register agent a
Message *specialMssg = new Message();
specialMssg->setAction(ChemoPopActionIDs::SPECIAL_AGENT_UPDATE_BLIND_AGENT_COUNT_ACTION_ID);
specialMssg->setArgument(new IntegerData("ChangeInBlindAgentNumber",1));
Registrar::getSystemRegistrar()->registerNewAgentAndSendMessageToSpecialAgent(a,specialMssg);
// Now, send the message to the world!!
Message *msg = new Message();
msg->setAction(ChemoPopActionIDs::UPDATE_WORLD_BLIND_AGENT_BIRTH_ACTION_ID);
msg->setDestinationID(destID);
//pass my agentID (the mother) and the new agent ID (the baby)
TVectorData<int> *info = new TVectorData<int>("new_cell_info","tvectordata_int");
info->addElementToEnd(this->source->getAgentId());
info->addElementToEnd(a->getAgentId()); // get new AgentID !!!
msg->setArgument(info);
source->placeMessageInOutbox(msg);
}
}