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


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

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


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

示例1:

vector<pair<Point, Cell::Direction> > RecursiveBacktrackerMaze::GetUnMarkedNeighbours(Point& cur)
{
  vector<pair<Point, Cell::Direction> > neighbours;

  for (auto dir : directions_)
    if (InBounds(cur.Direction(dir)) && !marked_.IsMarked(cur.Direction(dir)))
      neighbours.push_back(make_pair(cur.Direction(dir), dir));

  return neighbours;
}
开发者ID:BrandonSchaefer,项目名称:MazeGenerators,代码行数:10,代码来源:RecursiveBacktrackerMaze.cpp

示例2:

vector<pair<Point, Cell::Direction> > RecursiveBacktrackerMaze::GetUnMarkedNeighbours(Point& cur)
{
  vector<pair<Point, Cell::Direction> > neighbours;

  for (int i = 0; i < Cell::Direction::Size; ++i)
  {
    auto dir = Cell::Direction(i);
    if (InBounds(cur.Direction(dir)) && !marked_.IsMarked(cur.Direction(dir)))
      neighbours.push_back(make_pair(cur.Direction(dir), dir));
  }

  return neighbours;
}
开发者ID:BrandonSchaefer,项目名称:SDLMazeGenerator,代码行数:13,代码来源:RecursiveBacktrackerMaze.cpp

示例3: GenerateNext

void WilsonsMaze::GenerateNext()
{
  Point random_pt;
  Point walker;

  Cell::Direction random_dir;

  random_pt = GetRandomValidPoint(outside_cells_);
  walker = random_pt;

  while (!marked_.IsMarked(walker))
  {
    random_dir = GetValidRandomDirection(walker);
    paths_[walker.x()][walker.y()] = random_dir;
    walker = walker.Direction(random_dir);
  }

  while (!marked_.IsMarked(random_pt))
  {
    OpenPassage(random_pt, paths_[random_pt.x()][random_pt.y()]);
    marked_.Mark(random_pt);

    random_pt = random_pt.Direction(paths_[random_pt.x()][random_pt.y()]);
  }
}
开发者ID:BrandonSchaefer,项目名称:SDLMazeGenerator,代码行数:25,代码来源:WilsonsMaze.cpp

示例4: GetValidRandomDirection

Cell::Direction Maze::GetValidRandomDirection(Point& current)
{
  vector<Cell::Direction> valid_dirs;
  Point random_dir;
  Point tmp_pt;
  int randN;

  for (auto dir : directions_)
  {
    tmp_pt = current.Direction(dir);

    if (InBounds(tmp_pt))
      valid_dirs.push_back(dir);
  }

  randN = rand() % (valid_dirs.size());

  return valid_dirs[randN];
}
开发者ID:BrandonSchaefer,项目名称:MazeGenerators,代码行数:19,代码来源:Maze.cpp

示例5: marked

vector<Point> Solver::DFSolveRawMaze(RawMaze const& maze)
{
  vector<Point> path;
  Point current = maze.start;

  vector<vector<int>> raw_maze = maze.raw_maze;
  vector<vector<bool>> marked(raw_maze.size(), vector<bool>(raw_maze[0].size(), false));

  path.push_back(current);
  marked[current.x()][current.y()] = true;

  while (!path.empty())
  {
    current = path.back();

    if (maze.finish == current)
      return path;

    bool found = false;
    for (int i = 0; i < Cell::Direction::Size; ++i)
    {
      Point p = current.Direction(Cell::Direction(i));

      if (!raw_maze[p.x()][p.y()] && !marked[p.x()][p.y()])
      {
        path.push_back(p);
        marked[p.x()][p.y()] = true;
        found = true;
        break;
      }
    }

    if (!found)
      path.pop_back();
  }

  return path;
}
开发者ID:BrandonSchaefer,项目名称:SDLMazeGenerator,代码行数:38,代码来源:Solver.cpp

示例6: SetWall

void Maze::SetWall(Point p, Cell::Direction dir)
{
  Get(p).RemoveDirection(dir);
  Get(p.Direction(dir)).RemoveDirection(OppositeDirection(dir));
}
开发者ID:BrandonSchaefer,项目名称:MazeGenerators,代码行数:5,代码来源:Maze.cpp

示例7: OpenPassage

void Maze::OpenPassage(Point p, Cell::Direction dir)
{
  Get(p).AddDirection(dir);
  Get(p.Direction(dir)).AddDirection(OppositeDirection(dir));
}
开发者ID:BrandonSchaefer,项目名称:MazeGenerators,代码行数:5,代码来源:Maze.cpp


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