当前位置: 首页>>代码示例>>C++>>正文


C++ Agent类代码示例

本文整理汇总了C++中Agent的典型用法代码示例。如果您正苦于以下问题:C++ Agent类的具体用法?C++ Agent怎么用?C++ Agent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Agent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GoToPoint

/** 以最快的方式跑到目标点
* Run to the destination point with the fastest method.
* \param agent the agent itself.
* \param pos the destination point.
* \param buffer point buffer, means the real destinantion is a cycle with the certer 
* 		of pos and radius of buffer.
* \param power the intend power to use.
* \param can_inverse true means can run in the inverse direction of the agent's body.
* \param turn_first true means that the agent should turn first to adjust the direction.
* \return true if the action excuted successfully.
*/
bool Dasher::GoToPoint(Agent & agent, Vector pos, double buffer, double power, bool can_inverse, bool turn_first)
{
	AtomicAction act;

	GoToPoint(agent, act, agent.GetStrategy().AdjustTargetForSetplay(pos), buffer, power, can_inverse, turn_first);
	return act.Execute(agent);
}
开发者ID:girishbaranda,项目名称:WEFork_Guru,代码行数:18,代码来源:Dasher.cpp

示例2: readConfig

static void readConfig(Agent& agent, string configFile) {
    pt::ptree properties;

    LOG(INFO) << "Reading configuration from " << configFile;
    pt::read_json(configFile, properties);
    agent.setProperties(properties);
}
开发者ID:kuntenz,项目名称:opflex,代码行数:7,代码来源:main.cpp

示例3: main

int
main(int argc, char ** argv)
{
  int myid, numprocs;
  
  int n1, n2;
  n1 = atoi(argv[1]);
  n2 = atoi(argv[2]);
  
  if (n1 > 0){ ALL_N_AGENTS=n1; }
  if (n2 > 0){ N_TRIAL=n2; }
  Agent * agents = init(&argc, argv, &myid, &numprocs);

  if(myid == 0){
   printf("%d %d %d\n", ALL_N_AGENTS, N_AGENTS, N_TRIAL);
  }
  
  double new_price = 0;
  int t;
  for(t = 0; t < N_TRIAL; ++t)  {
    int i; 
    Agent * agent;
    
    for(agent = agents, i = N_AGENTS; i--; ++agent)
      agent->refresh(agent);

    double g_min_ask, g_max_bid;
    get_extreme_value(&g_min_ask, &g_max_bid, agents);

    if(myid == 0)
      if(g_max_bid > g_min_ask)
      {
        new_price = (g_min_ask + g_max_bid) / 2;
        printf("%d %lf\n", t, new_price);
//        fflush(stdout);
      }

    MPI_Bcast(&new_price, 1, MPI_DOUBLE, 0, MPI_COMM_WORLD);

    for(;new_price; new_price = 0)
      for(agent = agents, i = N_AGENTS; i--; ++agent)
        agent->set(agent, new_price);
  }

  MPI_Finalize();
  return 0;
}
开发者ID:qazzxc,项目名称:Agent-based-Market-Simulation,代码行数:47,代码来源:main.c

示例4:

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();
}
开发者ID:ideoforms,项目名称:phd,代码行数:17,代码来源:EnvironmentCA2DMulti.cpp

示例5: removeSource

    void LocationModel::removeSource(AgentId aid)
    {
        if(mSources.erase(aid) > 0)
        {
            Agent *agent = mLocationModelMan->level()->agentMan()->getAgent(aid);

            if(nullptr == agent)
                return;

            LocationModel *model = agent->locationModel();

            if(nullptr == model)
                return;

            model->removeDestination(attachedAgent());
        }
    }
开发者ID:onze,项目名称:Steel,代码行数:17,代码来源:LocationModel.cpp

示例6: logout

//##ModelId=424BB6470067
void ACDX::logout(CString agent)
{
	std::list<Agent>::iterator aliasElement;
	Agent ag;
	for(aliasElement = aliasList.begin(); aliasElement != aliasList.end(); ++aliasElement ) 
	{
		ag = *aliasElement;
		if (agent==(H323Utils::extractAliasName(ag.getAlias()))) 
		{
			if (g_lock.lock()) {
				aliasElement->setBlocked(TRUE);
				Logger::log("Logout agent " + agent);
				g_lock.unlock();
			}// lock
		}// ==
	}// for
}
开发者ID:princetoad,项目名称:acdx,代码行数:18,代码来源:acdx.cpp

示例7: RecordLuaComment

void CGameAIRecorder::RecordLuaComment(const Agent &agent, const char* szComment, ...) const
{
	assert(agent.IsValid());

	if (m_bIsRecording && agent.IsValid())
	{
		char szBuffer[1024] = {0};

		va_list args;
		va_start(args, szComment);
		vsnprintf(szBuffer, 1024, szComment, args);
		va_end(args);

		IAIRecordable::RecorderEventData data(szBuffer);
		agent.GetAIObject()->RecordEvent(IAIRecordable::E_LUACOMMENT, &data);
	}
}
开发者ID:danielasun,项目名称:dbho-GameSDK,代码行数:17,代码来源:GameAIRecorder.cpp

示例8: str

void ConfigTest::testIgnoreTimestampsOverride()
{
  istringstream str("Devices = ../samples/test_config.xml\n"
                    "IgnoreTimestamps = true\n"
                    "Adapters { LinuxCNC { \n"
                    "IgnoreTimestamps = false\n"
                    "} }\n");
  mConfig->loadConfig(str);
  
  Agent *agent = mConfig->getAgent();
  CPPUNIT_ASSERT(agent);
  Device *device = agent->getDevices()[0];
  Adapter *adapter = device->mAdapters[0];
  
  CPPUNIT_ASSERT(!adapter->isIgnoringTimestamps());
  
}
开发者ID:nikhilbchilwant,项目名称:cppagent,代码行数:17,代码来源:config_test.cpp

示例9: PlayerVehicle

Agent* AgentManager::createAgent(AgentType type, Creature* character)
{
	SteeringVehicle* vehicle = NULL;
	if(type == AGENT_PLAYER)
	{
		vehicle = new PlayerVehicle(character->getActor());
	}
    Agent* agent = new Agent(character, vehicle);
	agent->setType(type);
	if(type == AGENT_PLAYER)
	{
		mPlayer = agent;
	}

	addAgent(agent);
    return agent;
}
开发者ID:BackupTheBerlios,项目名称:dsa-hl-svn,代码行数:17,代码来源:AgentManager.cpp

示例10: end

Agent* AgentList::addOrUpdateAgent(sockaddr* publicSocket, sockaddr* localSocket, char agentType, uint16_t agentId) {
    AgentList::iterator agent = end();
    
    if (publicSocket) {
        for (agent = begin(); agent != end(); agent++) {
            if (agent->matches(publicSocket, localSocket, agentType)) {
                // we already have this agent, stop checking
                break;
            }
        }
    } 
    
    if (agent == end()) {
        // we didn't have this agent, so add them
        Agent* newAgent = new Agent(publicSocket, localSocket, agentType, agentId);
        
        if (socketMatch(publicSocket, localSocket)) {
            // likely debugging scenario with two agents on local network
            // set the agent active right away
            newAgent->activatePublicSocket();
        }
   
        if (newAgent->getType() == AGENT_TYPE_VOXEL_SERVER ||
            newAgent->getType() == AGENT_TYPE_AVATAR_MIXER ||
            newAgent->getType() == AGENT_TYPE_AUDIO_MIXER) {
            // this is currently the cheat we use to talk directly to our test servers on EC2
            // to be removed when we have a proper identification strategy
            newAgent->activatePublicSocket();
        }
        
        addAgentToList(newAgent);
        
        return newAgent;
    } else {
        
        if (agent->getType() == AGENT_TYPE_AUDIO_MIXER ||
            agent->getType() == AGENT_TYPE_VOXEL_SERVER) {
            // until the Audio class also uses our agentList, we need to update
            // the lastRecvTimeUsecs for the audio mixer so it doesn't get killed and re-added continously
            agent->setLastHeardMicrostamp(usecTimestampNow());
        }
        
        // we had this agent already, do nothing for now
        return &*agent;
    }    
}
开发者ID:Ventrella,项目名称:hifi,代码行数:46,代码来源:AgentList.cpp

示例11: main

int main(int argc, char *argv[]) {
    try {
        Agent agent {};

        try {
            agent.start();
        } catch (agent_error& e) {
            std::cout << "Failed to start the agent: " << e.what() << std::endl;
            return 2;
        }
    } catch (agent_error& e) {
        std::cout << "Failed to initialize the agent: " << e.what() << std::endl;
        return 1;
    }

    return 0;
}
开发者ID:puppetlabs,项目名称:cpp-pcp-client,代码行数:17,代码来源:main.cpp

示例12: Get_Totally_Complete

int Goal_Attack_Region::Get_Totally_Complete(AiMain *ai)
{

	int i;
	int completely_there_count = 0;

    Agent *agent = NULL;
    ArmyAgent *aa=NULL;
	MapPointData army_pos;


	if (attacking_squad == NULL) return false;

	for (i=0; i < attacking_squad->my_agents.count; i++)
	{

		agent = (Agent *) attacking_squad->my_agents.Return_Data_By_Number(i);

		if (agent->GetType() == AGENT_TYPE_ARMY)
		{

			aa = (ArmyAgent *) agent;

            if (aa->GetState() == AGENT_STATE_MARKED_DEAD) {
                continue;
            }

			aa->GetPos(ai, army_pos);

			if ((m_pos->x == army_pos.x)  &&
				(m_pos->y == army_pos.y)  &&
				(m_pos->z == army_pos.z)  )
			{

				completely_there_count++;

			}

		}

	}

    Set_Totally_Complete(completely_there_count == attacking_squad->my_agents.count);

	return m_is_completed;
}
开发者ID:jleclanche,项目名称:darkdust-ctp2,代码行数:46,代码来源:Goal_Attack_Region.cpp

示例13: reproduce

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;
}
开发者ID:ideoforms,项目名称:phd,代码行数:17,代码来源:EnvironmentGraph.cpp

示例14: playout

// simulate a sequence of random actions, returning the accumulated reward.
static reward_t playout(Agent &agent, unsigned int playout_len) {
	reward_t r = 0;
	for (unsigned int i = 0; i < playout_len; ++i) {
	    // Pick a random action
	    action_t a = agent.genRandomAction();
	    agent.modelUpdate(a);
		
		// Generate a random percept distributed according to the agent's
		// internal model of the environment.
        percept_t rew;
        percept_t obs;
	    agent.genPerceptAndUpdate(obs, rew);
	    
	    r = r + rew;
    }
	return r;
}
开发者ID:jkirschner42,项目名称:aixi,代码行数:18,代码来源:search.cpp

示例15: beatTrack

std::vector<double> beatTrack(const AgentParameters &params,
                              const EventList &events,
                              const EventList &beats)
      {
      AgentList agents;
      int count = 0;
      double beatTime = -1;
      if (!beats.empty()) {
            count = beats.size() - 1;
            EventList::const_iterator itr = beats.end();
            --itr;
            beatTime = itr->time;
            }
      if (count > 0) {        // tempo given by mean of initial beats
            double ioi = (beatTime - beats.begin()->time) / count;
            agents.push_back(new Agent(params, ioi));
            }
      else            // tempo not given; use tempo induction
            agents = Induction::beatInduction(params, events);

      if (!beats.empty()) {
            for (AgentList::iterator itr = agents.begin(); itr != agents.end(); ++itr) {
                  (*itr)->beatTime = beatTime;
                  (*itr)->beatCount = count;
                  (*itr)->events = beats;
                  }
            }
      agents.beatTrack(events, params, -1);

      Agent *best = agents.bestAgent();
      std::vector<double> resultBeatTimes;

      if (best) {
            best->fillBeats(beatTime);
            for (EventList::const_iterator itr = best->events.begin();
                        itr != best->events.end(); ++itr) {
                  resultBeatTimes.push_back(itr->time);
                  }
            }
      for (AgentList::iterator ai = agents.begin(); ai != agents.end(); ++ai) {
            delete *ai;
            }

      return resultBeatTimes;
      }
开发者ID:AdrianShe,项目名称:MuseScore,代码行数:45,代码来源:BeatTracker.cpp


注:本文中的Agent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。