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


C++ Point::Right方法代码示例

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


在下文中一共展示了Point::Right方法的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;
}
开发者ID:BrandonSchaefer,项目名称:SDLMazeGenerator,代码行数:53,代码来源:Solver.cpp

示例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;
}
开发者ID:BrandonSchaefer,项目名称:MazeGenerators,代码行数:46,代码来源:Solver.cpp

示例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;
}
开发者ID:BrandonSchaefer,项目名称:MazeGenerators,代码行数:13,代码来源:PrimsMaze.cpp


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