本文整理汇总了C++中Point::Left方法的典型用法代码示例。如果您正苦于以下问题:C++ Point::Left方法的具体用法?C++ Point::Left怎么用?C++ Point::Left使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point
的用法示例。
在下文中一共展示了Point::Left方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: marked
vector<Point> Solver::BFSolve(Maze::Ptr const& maze)
{
queue<vector<Point> > paths;
Point current = maze->GetStart();
vector<Point> path;
path.push_back(current);
paths.push(path);
vector<vector<bool> > marked(maze->Columns(), vector<bool>(maze->Rows(), false));
while (!paths.empty())
{
path = paths.front();
paths.pop();
current = path.back();
if (maze->GetFinish() == current)
return path;
if (maze->RightOpen(current) && !marked[current.Right().x()][current.Right().y()])
{
path.push_back(current.Right());
paths.push(path);
path.pop_back();
marked[current.Right().x()][current.Right().y()] = true;
}
if (maze->DownOpen(current) && !marked[current.Down().x()][current.Down().y()])
{
path.push_back(current.Down());
paths.push(path);
path.pop_back();
marked[current.Down().x()][current.Down().y()] = true;
}
if (maze->LeftOpen(current) && !marked[current.Left().x()][current.Left().y()])
{
path.push_back(current.Left());
paths.push(path);
path.pop_back();
marked[current.Left().x()][current.Left().y()] = true;
}
if (maze->UpOpen(current) && !marked[current.Up().x()][current.Up().y()])
{
path.push_back(current.Up());
paths.push(path);
path.pop_back();
marked[current.Up().x()][current.Up().y()] = true;
}
}
return path;
}
示例2: if
vector<Point> Solver::DFSolve(Maze::Ptr maze)
{
vector<Point> path;
Point current = maze->GetStart();
vector<vector<bool> > marked(maze->Columns(), vector<bool>(maze->Rows(), false));
path.push_back(current);
marked[current.x()][current.y()] = true;
while (!path.empty())
{
current = path.back();
if (maze->GetFinish() == current)
return path;
if (maze->RightOpen(current) && !marked[current.Right().x()][current.Right().y()])
{
// Add?
path.push_back(current.Right());
marked[current.Right().x()][current.Right().y()] = true;
}
else if (maze->DownOpen(current) && !marked[current.Down().x()][current.Down().y()])
{
path.push_back(current.Down());
marked[current.Down().x()][current.Down().y()] = true;
}
else if (maze->LeftOpen(current) && !marked[current.Left().x()][current.Left().y()])
{
path.push_back(current.Left());
marked[current.Left().x()][current.Left().y()] = true;
}
else if (maze->UpOpen(current) && !marked[current.Up().x()][current.Up().y()])
{
path.push_back(current.Up());
marked[current.Up().x()][current.Up().y()] = true;
}
else
{
path.pop_back();
}
}
return path;
}
示例3: GetOppositeParentsDirection
Cell::Direction PrimsMaze::GetOppositeParentsDirection(Point& current)
{
Cell cell = Get(current);
if (cell.GetParent() == &Get(current.Right()))
return Cell::Direction::LEFT;
else if (cell.GetParent() == &Get(current.Down()))
return Cell::Direction::UP;
else if (cell.GetParent() == &Get(current.Left()))
return Cell::Direction::RIGHT;
else
return Cell::Direction::DOWN;
}