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


C++ Maze::checkMaze方法代码示例

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


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

示例1: checkJump

 P_II checkJump(P_II now,P_II pre)
 {
     P_II dir=M_P(now.first-pre.first,now.second-pre.second);
     P_II tmp=M_P(-1,-1);
     if (mazer.checkMaze(now.first,now.second) == false)
         return tmp;
     if (now == end)
         return now;
     if (dir.first != 0 && dir.second != 0)
     {
         if ((mazer.checkMaze(now.first-dir.first,now.second+dir.second)
          && !mazer.checkMaze(now.first-dir.first,now.second))
         ||  (mazer.checkMaze(now.first+dir.first,now.second-dir.second)
          && !mazer.checkMaze(now.first,now.second-dir.second)))
             return now;
     }
     else
     {
         if (dir.first != 0)
         {
             if ((mazer.checkMaze(now.first+dir.first,now.second+1)
              && !mazer.checkMaze(now.first,now.second+1))
             ||  (mazer.checkMaze(now.first+dir.first,now.second-1)
              && !mazer.checkMaze(now.first,now.second-1)))
                 return now;
         }
         else
         {
             if ((mazer.checkMaze(now.first+1,now.second+dir.second)
              && !mazer.checkMaze(now.first+1,now.second))
             ||  (mazer.checkMaze(now.first-1,now.second+dir.second)
              && !mazer.checkMaze(now.first-1,now.second)))
                 return now;
         }
     }
     if (dir.first != 0 && dir.second != 0)
     {
         tmp=checkJump(M_P(now.first+dir.first,now.second),now);
         P_II t2=checkJump(M_P(now.first,now.second+dir.second),now);
         if (tmp.first != -1 ||  t2.first != -1)
             return now;
     }
     if (mazer.checkMaze(now.first+dir.first,now.second)
     ||  mazer.checkMaze(now.first,now.second+dir.second))
     {
         tmp=checkJump(M_P(now.first+dir.first,now.second+dir.second),now);
         if (tmp.first != -1)
             return tmp;
     }
     return tmp;
 }
开发者ID:eLRuLL,项目名称:JumpPointSearchAlgorithm,代码行数:51,代码来源:main.cpp

示例2: neighbourPrune

    V_PII neighbourPrune(Node c)
    {
        V_PII t;
        int i;
        P_II dir;
        t.clear();
        if (c.haveParent())
        {
            dir=c.getDirection();
            if (dir.first != 0 && dir.second != 0)
            {
                if (mazer.checkMaze(c.pos.first,c.pos.second+dir.second))
                        t.push_back(M_P(c.pos.first,c.pos.second+dir.second));

                if (mazer.checkMaze(c.pos.first+dir.first,c.pos.second))
                        t.push_back(M_P(c.pos.first+dir.first,c.pos.second));

                if (mazer.checkMaze(c.pos.first,c.pos.second+dir.second)
                ||  mazer.checkMaze(c.pos.first+dir.first,c.pos.second))
                        t.push_back(M_P(c.pos.first+dir.first,c.pos.second+dir.second));

                if (!mazer.checkMaze(c.pos.first-dir.first,c.pos.second)
                &&  mazer.checkMaze(c.pos.first,c.pos.second+dir.second))
                        t.push_back(M_P(c.pos.first-dir.first,c.pos.second+dir.second));

                if (!mazer.checkMaze(c.pos.first,c.pos.second-dir.second)
                &&  mazer.checkMaze(c.pos.first+dir.first,c.pos.second))
                        t.push_back(M_P(c.pos.first+dir.first,c.pos.second-dir.second));
            }
            else
            {
                if (dir.first == 0)
                {
                    if (mazer.checkMaze(c.pos.first,c.pos.second+dir.second))
                    {
                        if (mazer.checkMaze(c.pos.first,c.pos.second+dir.second))
                                t.push_back(M_P(c.pos.first,c.pos.second+dir.second));

                        if (!mazer.checkMaze(c.pos.first+1,c.pos.second))
                                t.push_back(M_P(c.pos.first+1,c.pos.second+dir.second));

                        if (!mazer.checkMaze(c.pos.first-1,c.pos.second))
                                t.push_back(M_P(c.pos.first-1,c.pos.second+dir.second));
                    }
                }
                else
                {
                    if (mazer.checkMaze(c.pos.first+dir.first,c.pos.second))
                    {
                        if (mazer.checkMaze(c.pos.first+dir.first,c.pos.second))
                                t.push_back(M_P(c.pos.first+dir.first,c.pos.second));

                        if (!mazer.checkMaze(c.pos.first,c.pos.second+1))
                                t.push_back(M_P(c.pos.first+dir.first,c.pos.second+1));

                        if (!mazer.checkMaze(c.pos.first,c.pos.second-1))
                                t.push_back(M_P(c.pos.first+dir.first,c.pos.second-1));
                    }
                }
            }
        }
        else
        {
            for (i=0; i<4; i++)
            {
                if (mazer.checkMaze(c.pos.first+g_dir[i][0],c.pos.second+g_dir[i][1]))
                        t.push_back(M_P(c.pos.first+g_dir[i][0],c.pos.second+g_dir[i][1]));
            }

            if (mazer.checkMaze(c.pos.first+1,c.pos.second) || mazer.checkMaze(c.pos.first,c.pos.second+1))
            {
                if (mazer.checkMaze(c.pos.first+1,c.pos.second+1))
                    t.push_back(M_P(c.pos.first+1,c.pos.second+1));
            }

            if (mazer.checkMaze(c.pos.first+1,c.pos.second) || mazer.checkMaze(c.pos.first,c.pos.second-1))
            {
                if (mazer.checkMaze(c.pos.first+1,c.pos.second-1))
                {

                    t.push_back(M_P(c.pos.first+1,c.pos.second-1));
                }
            }
            if (mazer.checkMaze(c.pos.first-1,c.pos.second) || mazer.checkMaze(c.pos.first,c.pos.second+1))
            {
                if (mazer.checkMaze(c.pos.first-1,c.pos.second+1))
                    t.push_back(M_P(c.pos.first-1,c.pos.second+1));
            }
            if (mazer.checkMaze(c.pos.first-1,c.pos.second) || mazer.checkMaze(c.pos.first,c.pos.second-1))
            {
                if (mazer.checkMaze(c.pos.first-1,c.pos.second-1))
                    t.push_back(M_P(c.pos.first-1,c.pos.second-1));
            }
        }
        for (i=0; i<t.size(); i++)
        {
            printf("%d %d\n",t[i].first,t[i].second);
        }
        return t;
    }
开发者ID:eLRuLL,项目名称:JumpPointSearchAlgorithm,代码行数:100,代码来源:main.cpp


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