4#include <unordered_map>
5#include <unordered_set>
11#include <boost/filesystem.hpp>
14#define GLM_ENABLE_EXPERIMENTAL
15#include "glm/gtx/hash.hpp"
17#define REQUIRED_NUM_ROOMS 100
57static std::unordered_map<RoomSize, std::vector<glm::ivec2>> TOP_ENTRY_COORDS = {
60 {
RoomSize::_40x40, {{4, 0}, {5, 0}, {14, 0}, {15, 0}, {24, 0}, {25, 0}, {34, 0}, {35, 0}} },
62static std::unordered_map<RoomSize, std::vector<glm::ivec2>> LEFT_ENTRY_COORDS = {
65 {
RoomSize::_40x40, {{0, 4}, {0, 5}, {0, 14}, {0, 15}, {0, 24}, {0, 25}, {0, 34}, {0, 35}} },
67static std::unordered_map<RoomSize, std::vector<glm::ivec2>> BOTTOM_ENTRY_COORDS = {
70 {
RoomSize::_40x40, {{4, 39}, {5, 39}, {14, 39}, {15, 39}, {24, 39}, {25, 39}, {34, 39}, {35, 39}} },
72static std::unordered_map<RoomSize, std::vector<glm::ivec2>> RIGHT_ENTRY_COORDS = {
75 {
RoomSize::_40x40, {{39, 4}, {39, 5}, {39, 14}, {39, 15}, {39, 24}, {39, 25}, {39, 34}, {39, 35}} },
84 return this->type == other.
type && this->size == other.
size && this->entries == other.
entries;
91 boost::hash_combine(seed, p.
type);
92 boost::hash_combine(seed, p.
size);
93 boost::hash_combine(seed, p.
entries);
108 bool operator()(
const glm::ivec2& lhs,
const glm::ivec2& rhs)
const {
115 return (lhs.y < rhs.y);
119#define GRID_CELLS_PER_ROOM 10
128 RoomType _getRoomType(boost::filesystem::path path);
129 RoomSize _parseRoomSize(
int rows,
int columns);
130 uint8_t _identifyEntryways(
Grid& grid);
133 std::vector<glm::ivec2> _getRoomCoordsTakenBy(
RoomSize size, glm::ivec2 top_left);
135 std::shared_ptr<Room> _pullRoomByPolicy();
142 std::vector<std::pair<glm::ivec2, RoomEntry>> _getAdjRoomCoords(std::shared_ptr<Room> room, glm::ivec2 origin_coord);
148 std::queue<std::pair<glm::ivec2, RoomEntry>> frontier;
149 void _placeRoom(std::shared_ptr<Room> room, glm::ivec2 origin_coord);
151 bool _isOpenWorldCoord(glm::ivec2 coord);
153 std::vector<glm::ivec2> _getPossibleOriginCoords(std::shared_ptr<Room> room,
RoomEntry required_entry, glm::ivec2 connect_coord);
155 std::map<glm::ivec2, int, ivec2_comparator> maze;
157 void _loadRoom(boost::filesystem::path path,
bool procedural);
158 std::unordered_map<RoomClass, std::shared_ptr<Room>,
RoomClassHash> rooms_by_class;
159 std::unordered_map<RoomType, std::vector<std::shared_ptr<Room>>> rooms_by_type;
160 std::unordered_map<int , std::shared_ptr<Room>> rooms_by_id;
164 void _generatePolicy();
166 int _num_rooms_placed;
167 std::deque<RoomType> _policy;
172 std::unordered_set<int> used_room_ids;
Definition: mazegenerator.hpp:121
std::optional< Grid > generate()
Definition: mazegenerator.cpp:57
GLuint id
Definition: glad.h:1776
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glad.h:1531
GLsizeiptr size
Definition: glad.h:1803
RoomType
Definition: mazegenerator.hpp:19
RoomSize
Definition: mazegenerator.hpp:50
RoomEntry
Definition: mazegenerator.hpp:43
@ R
Definition: mazegenerator.hpp:47
@ T
Definition: mazegenerator.hpp:44
@ B
Definition: mazegenerator.hpp:45
@ L
Definition: mazegenerator.hpp:46
Definition: config.hpp:12
Definition: mazegenerator.hpp:88
size_t operator()(const RoomClass &p) const
Definition: mazegenerator.hpp:89
Definition: mazegenerator.hpp:78
RoomSize size
Definition: mazegenerator.hpp:80
bool operator==(const RoomClass &other) const
Definition: mazegenerator.hpp:83
uint8_t entries
Definition: mazegenerator.hpp:81
RoomType type
Definition: mazegenerator.hpp:79
Definition: mazegenerator.hpp:98
Grid grid
Definition: mazegenerator.hpp:102
RoomClass rclass
Definition: mazegenerator.hpp:103
Room(Grid &&grid, const RoomClass &rclass, int id)
Definition: mazegenerator.hpp:99
int id
Definition: mazegenerator.hpp:104
Definition: mazegenerator.hpp:107
bool operator()(const glm::ivec2 &lhs, const glm::ivec2 &rhs) const
Definition: mazegenerator.hpp:108