65 std::size_t
operator()(
const H3Index &index)
const {
return std::hash<uint64_t>()(index); }
73 std::unordered_set<H3Index>
walls;
87 std::unordered_set<H3Index>
generateMaze(H3Index centerCell,
int radius);
112 void generationProgress(
int percent);
141 static std::unordered_set<H3Index, H3IndexHash>
getCellsInRadius(H3Index center,
int radius);
152 std::unordered_set<H3Index, H3IndexHash>
createRoomGrid(
const std::unordered_set<H3Index, H3IndexHash> &allCells);
172 std::unordered_set<H3Index, H3IndexHash>
generateMazePrim(
const std::unordered_set<H3Index, H3IndexHash> &rooms);
181 static std::vector<H3Index>
getRoomNeighbors(H3Index room,
const std::unordered_set<H3Index, H3IndexHash> &rooms);
192 H3Index
findFarthestRoom(H3Index start,
const std::unordered_set<H3Index, H3IndexHash> &passages);
202 static bool isOnBorder(H3Index cell, H3Index center,
int radius);
Generates perfect mazes on H3 hexagonal grids.
~H3MazeGenerator() override=default
Default destructor.
H3Index exit
Exit point cell index.
std::array< H3Index, 6 > getNeighbors(H3Index cell)
Gets the 6 neighbors of a hexagonal cell.
static std::vector< H3Index > getRoomNeighbors(H3Index room, const std::unordered_set< H3Index, H3IndexHash > &rooms)
Gets rooms that are neighbors at distance 2.
MazeResult generateMazeWithEntrances(H3Index centerCell, int radius)
Generates a maze with entrance and exit points.
std::unordered_set< H3Index, H3IndexHash > generateMazePrim(const std::unordered_set< H3Index, H3IndexHash > &rooms)
Generates maze passages using randomized Prim's algorithm.
std::unordered_set< H3Index, H3IndexHash > createRoomGrid(const std::unordered_set< H3Index, H3IndexHash > &allCells)
Creates a sparse room grid with minimum 2-cell spacing.
std::unordered_set< H3Index > generateMaze(H3Index centerCell, int radius)
Generates a maze centered at the given cell.
H3Index entrance
Entry point cell index.
std::array< H3Index, 6 > neighbors_
Temporary storage for neighbor cells.
void mazeGenerated(const std::unordered_set< H3Index > &walls)
Emitted when maze generation is complete.
std::unordered_set< H3Index > walls
Set of wall cell indices.
std::optional< H3Index > findWallBetween(H3Index room1, H3Index room2)
Finds the wall cell between two rooms.
static bool isOnBorder(H3Index cell, H3Index center, int radius)
Checks if a cell is on the border of the maze area.
static std::unordered_set< H3Index, H3IndexHash > getCellsInRadius(H3Index center, int radius)
Gets all cells within a radius of the center.
std::mt19937 rng_
Random number generator for maze randomization.
H3Index findFarthestRoom(H3Index start, const std::unordered_set< H3Index, H3IndexHash > &passages)
Finds the room farthest from the start using BFS.
Result structure containing generated maze data.
Hash function for H3Index in unordered containers.
std::size_t operator()(const H3Index &index) const