Work-in-progress C++23 library for procedural finite map generation.
- seed-defined RNG: Regenerate identical maps with the same seed.
- random graph embedding: Used for placement of key map objects as well as zone system.
- zone system: Prepare a logistic graph of zones to bloat a map with specified regions and their connections.
- step-by-step simulation: Inspect each generation step for debugging/visualization.
- zone and connection templates: Extend the features to fit your requirements (e.g. biomes, roads)
Graph embedding:
Zone bloat:
#include <rasterization.h>
#include <templates.h>
#include <embedding.h>
#include <grid.h>
#include <zone_bloater.h>
/**
* Generates a 128x128 map using a 3x3 grid template.
* Steps:
* 1. Embeds the template into a plane with force-directed layout.
* 2. Rasterizes the plane into a grid.
* 3. Expands zones via Voronoi bloating.
*/
std::shared_ptr<Grid<BasicNode>> generateMap() {
// --- Phase 1: Graph Embedding ---
EmbeddablePlane<BasicNode> embedding(128, 128);
embedding.initEmbed(templates::grid3x3); // Predefined 3x3 grid
while (embedding.stepForceDirected()) { // Runs until layout stabilizes
#if 0 // Debug: Uncomment to log positions
for (const auto& id : embedding.getIDs()) { ... }
#endif
}
// --- Phase 2: Rasterization ---
auto map = std::make_shared<Grid<BasicNode>>(safeRasterizePlane(embedding));
// --- Phase 3: Zone Expansion ---
ZoneBloater<BasicNode> zoneBloater;
zoneBloater.initVoronoi(templates::grid3x3, map);
zoneBloater.start();
while (zoneBloater.step()) { // Progressively expands zones
#if 0 // Debug: Uncomment to inspect tiles
std::cout << "Progress: " << zoneBloater.getProgress() << "%\n";
#endif
}
return map; // Final generated map
}Generation result:
Example output using grid3x3 template
GenCore is built with CMake. To use it in your project:
- Clone the repository or add it as a submodule to your project:
git clone https://github.com/he1kor/GenCore.git- Add to your CMake project:
add_subdirectory(path/to/GenCore)
target_link_libraries(your_target_name PUBLIC GenCore)

