本文整理汇总了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;
}
示例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;
}