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


C++ Agent::getPotentialInformation方法代码示例

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


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

示例1: solveConflicts

void PathFinder::solveConflicts(GoalTypes goalType, std::map<KeyType, Agent*>& agents)
{
	Agent* pFirstAgent = NULL;
	Agent* pCollidingAgent = NULL;
	std::map<FixedCoordinate, KeyType, FixedCoordinateCompare>::iterator keyIt;
	std::map<KeyType, Agent*>::iterator agentIt;

	switch (goalType) {
		case GoalType_Goal:
			while (!mCollidingAgents.empty())
			{
				pCollidingAgent = mCollidingAgents.getFirst();
				//pFirstAgent = agents[mAgentGoalPositions[pCollidingAgent->getPotentialInformation().getBestGoalPosition()]];
				keyIt = mAgentGoalPositions.find(pCollidingAgent->getPotentialInformation().getBestGoalPosition());
				assert(keyIt != mAgentGoalPositions.end());
				agentIt = agents.find(keyIt->second);
				assert(agentIt != agents.end());
				pFirstAgent = agentIt->second;
				solveGoalConflict(pFirstAgent, pCollidingAgent);
				mCollidingAgents.removeFirst();
			}
			break;

			
		case GoalType_NextGoal:
			while (!mCollidingAgents.empty())
			{
				pCollidingAgent = mCollidingAgents.getFirst();
				//pFirstAgent = agents[mAgentNextGoalPositions[pCollidingAgent->getPotentialInformation().getBestNextGoalPosition()]];
				keyIt = mAgentNextGoalPositions.find(pCollidingAgent->getPotentialInformation().getBestNextGoalPosition());
				assert(keyIt != mAgentNextGoalPositions.end());
				agentIt = agents.find(keyIt->second);
				assert(agentIt != agents.end());
				pFirstAgent = agentIt->second;
				solveNextGoalConflict(pFirstAgent, pCollidingAgent);
				mCollidingAgents.removeFirst();
			}
			break;
	}
}
开发者ID:GustavPersson,项目名称:miniature-dubstep,代码行数:40,代码来源:PathFinder.cpp

示例2: printMap

void PathFinder::printMap()
{
	KeyType agentMap[MAP_WIDTH][MAP_HEIGHT];
	KeyType enemyMap[MAP_WIDTH][MAP_HEIGHT];

	for (int i = 0; i < MAP_WIDTH; i++)
	{
		for (int j = 0; j < MAP_HEIGHT; j++)
		{
			agentMap[i][j] = INVALID_KEY;
		}
	}

	for (int i = 0; i < MAP_WIDTH; i++)
	{
		for (int j = 0; j < MAP_HEIGHT; j++)
		{
			enemyMap[i][j] = INVALID_KEY;
		}
	}

	// Iterate through all the agents and put the key in the local map
	std::map<KeyType, Agent*>* agents = mpAgentHandler->checkOutAllAgents();
	std::map<KeyType, Agent*>::iterator agentIt;
	for (agentIt = agents->begin(); agentIt != agents->end(); ++agentIt)
	{
		Coordinate position = agentIt->second->getPosition();
		agentMap[static_cast<int>(position.x+0.5f)][static_cast<int>(position.y+0.5f)] = agentIt->first;
	}
	mpAgentHandler->checkInAllAgents();

	// Iterate through all the enemies
	std::map<KeyType, Enemy*>* enemies = mpEnemyHandler->checkOutAllEnemies();
	std::map<KeyType, Enemy*>::iterator enemyIt;
	for (enemyIt = enemies->begin(); enemyIt != enemies->end(); ++enemyIt)
	{
		FixedCoordinate position = enemyIt->second->getPosition();
		enemyMap[position.x][position.y] = enemyIt->first;
	}
	mpEnemyHandler->checkInAllEnemies();

	// Print the map
	std::list<std::wostream*>::iterator it;
	for (it = mpOutStreams->begin(); it != mpOutStreams->end(); ++it)
	{
		printLine(**it, true);
		std::wstring text;
		std::wstringstream ss;
		std::wostream& out = **it;

		for (int height = 0; height < MAP_HEIGHT; height++)
		{
			// Print the id
			for (int width = 0; width < MAP_WIDTH; width++)
			{
				ss.clear();
				text = L"";
				// Check the agent and enemy map
				if (agentMap[width][height] != INVALID_KEY)
				{
					ss << agentMap[width][height];
				}
				else if (enemyMap[width][height] != INVALID_KEY)
				{
					ss << enemyMap[width][height];
				}
				ss >> text;

				out << L"|" << std::setw(5) << text;
			}
			out << L"|" << std::endl;

			// Print additional information
			for (int width = 0; width < MAP_WIDTH; width++)
			{
				// Check the agent and enemy map
				if (agentMap[width][height] != INVALID_KEY)
				{
					// get the goal position
					Agent* pAgent = mpAgentHandler->checkOutAgent(agentMap[width][height]);
					FixedCoordinate goal = pAgent->getPotentialInformation().getBestGoalPosition();
					FixedCoordinate nextGoal = pAgent->getPotentialInformation().getBestNextGoalPosition();
					mpAgentHandler->checkInAgent(agentMap[width][height]);

					// current position
					FixedCoordinate curPos;
					curPos.x = width;
					curPos.y = height;

					text = getArrow(curPos, goal);
					text += L" ";
					text += getArrow(goal, nextGoal);
				}
				else if (enemyMap[width][height] != INVALID_KEY)
				{
					text = L"XXXXX";
				}
				else
				{
					text = L"";
//.........这里部分代码省略.........
开发者ID:GustavPersson,项目名称:miniature-dubstep,代码行数:101,代码来源:PathFinder.cpp


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