本文整理汇总了C++中Agent::getPos方法的典型用法代码示例。如果您正苦于以下问题:C++ Agent::getPos方法的具体用法?C++ Agent::getPos怎么用?C++ Agent::getPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Agent
的用法示例。
在下文中一共展示了Agent::getPos方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendMsg
bool Env::sendMsg(long idSrc, long idDest, char *msg) {
logMsg("SEND MSG : " + std::to_string(idSrc) + " -> " + std::to_string(idDest));
// if (this->phy->getNeighbours(idSrc).count(idDest)) {
this->agents.at(idDest)->addMsg(msg);
// Display the sending message with dataAgents
Agent * agentSrc = this->agents.at(idSrc);
Agent * agentDest = this->agents.at(idDest);
Vect posSrc = PosToCell(agentSrc->getPos().x, agentSrc->getPos().y);
Vect posDest = PosToCell(agentDest->getPos().x, agentDest->getPos().y);
if (posSrc != posDest) {
float dist = ((724-Vect(posSrc - posDest).Length()) / 724.0) / 6.0;
for (float n = 0; n < 1; n += dist) {
Vect base = posDest + n * (posSrc - posDest);
Vect dirSommet = Vect(posSrc - posDest);
dirSommet.Normalize();
Vect vectBase = Vect(dirSommet.y, -dirSommet.x);
for (int j = 0; j < 20; j++) {
for (int i = -j*0.5; i <= j*0.5; i++) {
Vect point = base + j / 2.0 * dirSommet + i / 2.0 * vectBase;
if (point.x >= 0 && point.x < 512 && point.y >= 0 && point.y < 512) {
agentSrc->getVision(point.x, point.y)->dataAgent = 10 * (1 - n);
}
}
}
}
}
return true;
//}
//return false;
}
示例2: addAgent
Agent* Env::addAgent(float range, float speed) {
int idAgent = this->agents.size();
Agent *agent = new Agent(idAgent, phy, range/this->W, speed, (EnvAgents*)this);
this->phy->addAgent(idAgent, agent->getPos(), agent->getAngle(), agent->getSize(), agent->getRange()/this->W);
this->agents.insert(pair<long, Agent*>(idAgent, agent));
this->phy->setMaxSpeed(idAgent, speed);
return agent;
}
示例3: getRealConnectivities
void SWGraph::getRealConnectivities(ofstream& fp){
// Para cada agente obtener su posicion
// y con esa posicion buscar los vecinos
// y contarlos.
list<Agent*> vecinos;
Agent* a = NULL;
Position* pos=NULL;
set<Agent*>::iterator i;
for (i = agents.begin(); i != agents.end(); ++i) {
a = *i;
pos = a->getPos();
vecinos = getNeighbourgs(pos);
//cout << a->getId()<< "\t" << vecinos.size()<<"\n";
fp << a->getId()<< "\t" << vecinos.size()<<"\n";}
}