Quick Overview
2 min read
Video demo of what the generator is capable of.
Video demo of what the generator is capable of.
Scenario
- The metropolis is a vast and complex entity comprising of many structures distinguished by an array of architectural variations. From towering skyscrapers to picturesque parks, the cityscape is a testament to the diversity of human ingenuity.
- In this context, the 'structure' submodule was devised with the purpose of centralising the creation of all types of urban structures, from recreational spaces to medical facilities and residential quarters.
Challenge ~ Structure Generation
- The uncoordinated generation of structures can lead to a chaotic codebase that is hard to maintain and extend, thereby hindering the ability to support new structures.
- Thus, the task was to craft a centralised and robust generation engine that could produce a diverse set of structures that could accommodate the myriad types of urban edifices.
Solution ~ 3D Graphs

- To meet this challenge, we employed the use of 3D graphs, where cells, the smallest unit of buildable space, are interconnected to form a three-dimensional representation of the build area.
- During the generation process, traversed cells are transformed into a generative type, and this traversal can be modified using a lambda predicate. This feature is vital in enabling the generator to function for a wide range of structures.
- Examples of this implementation include:
- Traversing upwards to create a spire for a skyscraper
- Traversing in a column to create a grand hallway in a library
- Traversing on "level_access" cell types to create a grand spiral staircase
- Traversing only on a level above the ground level to create a high-ceilinged hotel lobby.
Challenge ~ Modularity, Extensibility, and Reusability
- To ensure the submodule's flexibility, it was imperative to enable contributors to add their own custom structures to the codebase easily. However, despite their architectural variations, buildings share common properties such as walls, roofs, and doors.
- Without a cohesive submodule framework, each addition would be plagued by convoluted access to internal APIs, an unorganised code structure, and unmaintainable code.
Solution ~ Design Patterns!