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


C++ Attr::Attrs1方法代码示例

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


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

示例1: main

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//                            MAIN PROGRAM START
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int main()
{
   Attr test;
   test.Load();
   test.Attrs1();
  AStar();
}
开发者ID:KidGundam,项目名称:Artificial_Intelligence,代码行数:10,代码来源:A-Star-Search.C

示例2: 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();
//.........这里部分代码省略.........
开发者ID:KidGundam,项目名称:Artificial_Intelligence,代码行数:101,代码来源:A-Star-Search.C


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