本文整理汇总了C++中Attr::Euclidean方法的典型用法代码示例。如果您正苦于以下问题:C++ Attr::Euclidean方法的具体用法?C++ Attr::Euclidean怎么用?C++ Attr::Euclidean使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Attr
的用法示例。
在下文中一共展示了Attr::Euclidean方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AStar
//============================================================================
// A-Star-Search Algorithm
// ---Start---
//============================================================================
void AStar()
{
priority_queue<tracker, vector<tracker>, gTracker> CloseList;
priority_queue<tracker, vector<tracker>, gTracker> OpenList;
priority_queue<tracker, vector<tracker>, gTracker> TempOpenList;
priority_queue<tracker, vector<tracker>, gTracker> TempCloseList;
int begin;
int last;
int top;
int temp;
int values;
int sTemp1 = 0;
int sTemp2 = 0;
int frontier = 0;
bool rNext = false;
bool closeCheck = false;
tracker tracking;
tracker closeT;
tracker checkT;
tracker tempT;
vector<tracker> trackTemp;
vector<float> lFind;
Attr dist;
begin = attrs[0].letters[0].value;
for(int r = 0; r <= attrs.size()-1; r++)
{
for(int c = 0; c <= attrs[r].letters.size()-1; c++)
lFind.push_back(attrs[r].letters[c].value);
}
sort(lFind.begin(),lFind.end(),compare());
last = lFind[0];
cout<<"The goal is: "<<last<<endl;
cout<<"The begin is: "<<begin<<endl;
cout<<"Euclidean distance: "<<dist.Euclidean(begin,last)<<endl;
tracking.asci = begin;
tracking.gS = dist.Euclidean(0, begin);
tracking.hS = dist.Euclidean(last, begin);
tracking.fN = tracking.gS + tracking.hS;
OpenList.push(tracking);
while(!OpenList.empty())
{
tempT = OpenList.top();
cout<<"tempT is: "<<tempT.asci<<endl;
if(frontier < OpenList.size())
frontier = OpenList.size();
OpenList.pop();
//First I am obtaining the blocks that are next to tempT.asci
//FIX: Iterator in order to move to the next row if it is available
for(int s1 = 0; s1 <= tempAttr.size()-1; s1++)
{
for(int s2 = 0; s2 <= tempAttr[s1].letters.size()-1; s2++)
{
if(tempT.asci == tempAttr[s1].letters[s2].value)
{
sTemp1 = s1;
sTemp2 = s2;
dist.Attrs1();
//vector<Attr> tempAttr(3);
if(tempAttr[s1].letters[s2].id == 0)
{
if(s2 == 0 && tempAttr[s1].letters[sTemp2+1].value != 0)
{
//no left neighbor
temp = tempAttr[s1].letters[sTemp2+1].value;
//remove letter from temp adj list
//tempAttr.erase(remove(tempAttr.begin(), tempAttr.end(), temp), tempAttr.end());
//tempAttr.resize(tempAttr.size());
cout<<"the right 3 neighbor is: "<<temp<<endl;
tracking.asci = temp;
tracking.gS = dist.Euclidean(temp,tempT.asci);
cout<<"the right 3 neighbor gS is: "<<tracking.gS<<endl;
tracking.hS = dist.Euclidean(temp,last);
cout<<"the right 3 neighbor hS is: "<<tracking.hS<<endl;
tracking.fN = tracking.gS + tracking.hS;
cout<<"the right 3 neighbor fN is: "<<tracking.fN<<endl;
OpenList.push(tracking);
trackTemp.push_back(tracking);
cin.get();
//.........这里部分代码省略.........