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


C++ path::clear方法代码示例

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


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

示例1: findPathA

int findPathA(cell start,cell end,path& best_path,tilemap& t_map, double (*h)(cell x,cell y) )
{
	int width = 0;
	int height = 0;
	int is_ok = 0;
	cell current;
	
	width = t_map[0].size();
	height = t_map.size();

	costmap G(height,std::vector<double>(width, infinite));
	costmap F(height,std::vector<double>(width, infinite));

	G[start.second][start.first] = 0;
	F[start.second][start.first] = G[start.second][start.first] + dist_coeff*h(start,end);

	std::set<cell > wawe;
	std::set<cell > closed;
	std::map<cell,cell > from;
	std::set<cell > unclosedNeighbours; 
	
	from[start] = start;
	wawe.insert(start);

	while(!wawe.empty())
	{
		current = findMinF(wawe,F);
		if(current == end){is_ok = 1;break;}

		wawe.erase(current);
		closed.insert(current);
		getUnclosedNeighbours(current,t_map,closed,unclosedNeighbours);
		for(auto it = unclosedNeighbours.begin();it != unclosedNeighbours.end();it++)
		{
			double temp_G = G[current.second][current.first] + transition_cost(from[current],current,*it);
			if(wawe.count(*it) == 0 || temp_G < G[it->second][it->first])
			{
				from[*it] = current;
				G[it->second][it->first] = temp_G;
				F[it->second][it->first] = G[it->second][it->first] + dist_coeff*h(*it,end);
				wawe.insert(*it);
			}
		}
	}

	if(!is_ok) return -1;
	
	best_path.clear();
	best_path.push_back(end);
	
	while(current != start)
	{
		best_path.push_back(from[current]); 
		current = from[current];
	}

	best_path = std::vector<cell >(best_path.rbegin(),best_path.rend());
	return 0;
}
开发者ID:grauwolf32,项目名称:AICup,代码行数:59,代码来源:as.cpp

示例2: clear

 void clear()
 {
  _self_path.clear();
  _target.clear();
  _make.clear();
 }
开发者ID:vmorgulys,项目名称:sandbox,代码行数:6,代码来源:class.starter.cpp


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