本文整理汇总了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;
}
示例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;
}
示例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()]);
}
}
示例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];
}
示例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;
}
示例6: SetWall
void Maze::SetWall(Point p, Cell::Direction dir)
{
Get(p).RemoveDirection(dir);
Get(p.Direction(dir)).RemoveDirection(OppositeDirection(dir));
}
示例7: OpenPassage
void Maze::OpenPassage(Point p, Cell::Direction dir)
{
Get(p).AddDirection(dir);
Get(p.Direction(dir)).AddDirection(OppositeDirection(dir));
}