Emre Uğur · Leiden University · GameAI 2024

Minecraft Settlement Generation Using Evolutionary Algorithms

A system that takes an arbitrary Minecraft build area, searches for suitable spots for a village using a genetic algorithm, and constructs all the buildings using procedural and modular techniques.

A generated settlement at night
Desert settlement
Desert
Dark forest settlement
Dark forest

The goal was to build a settlement that looks natural in the terrain it lands on. That means finding the flattest, most natural spots, minimising how much the terrain has to be reshaped, and making sure the village has some spatial coherence (houses clustered together, worship place visible from everywhere).

The whole pipeline runs sequentially: a genetic algorithm figures out the layout, then the builder modules go through and construct everything from the ground up. Each run produces a different result.

Placement search

Finding good spots for 11 houses and a worship place simultaneously is a hard combinatorial problem. Testing every possible layout is infeasible — the search space grows as O((l·m)n). A greedy approach (place one building at a time, pick the best remaining spot) works for small n, but for 12 buildings the later placements consistently end up in suboptimal locations because the good spots are already taken.

Instead, all 12 positions are searched at once using a genetic algorithm. Each candidate solution is a bitstring that encodes the X and Z coordinates of every building. The algorithm runs for 1000 generations with a population of 50, using tournament selection, per-section uniform crossover, and bit-flip mutation (rate 0.01).

Settlement overview
A completed settlement — buildings cluster around the central worship place naturally

Fitness function

The fitness function combines ten signals into one cost (lower is better):

  1. Terrain modification cost — total blocks added or removed to flatten each site to its mean height. The main driver.
  2. Overlap penalty — large penalty if any two building footprints intersect.
  3. Out-of-bounds penalty — large penalty if a footprint extends outside the designated area.
  4. Water penalty — penalty if more than two corners of a site sit over open water. Two corners over water is allowed — that creates a natural waterfront terrace.
  5. Hierarchy penalty — the worship place must sit at least as high as every house; violated placements are penalised.
  6. Proximity penalty — houses placed too close to the worship place incur a proportional penalty that fades with distance.
  7. Clustering cost — mean pairwise squared distance between all building centres; encourages a compact layout.
  8. Octant penalty — the 360° around the worship place is split into 8 wedges; each empty wedge adds a penalty, so it ends up surrounded on all sides.
  9. Centroid-offset penalty — penalises the worship place for being far from the average centre of all the houses.
  10. LOF outlier penalty — applies the Local Outlier Factor density score to penalise any building that is isolated relative to its neighbours.

House construction

Each house is generated by placing two or three rectangles inside the 10×10 plot, then substituting each rectangular storey with a hand-designed modular structure. Rectangle footprints are chosen from three options: (4×3), (5×5), or (7×4). Each rectangle gets a random story count of 1, 2, or 3, each storey being 5 blocks tall.

Block-coded floor outlines
Floor roles before modules are applied — sand: entrance, oak: middle floor, cobblestone: roof
The 9 modular units
The 9 modular units — one entrance, middle, and roof variant per footprint size

The placement of rectangles follows a generate-and-test approach. The first rectangle goes in a random valid position. Each subsequent rectangle picks a random corner of an existing one and applies a random inward offset, so they always overlap enough for the interiors to connect. A small set of offsets that would produce corner-only contact is excluded because those make the interior layout unsolvable. 3-storey blocks are also constrained to attach to the tallest existing rectangle, which prevents double peaks.

Bottom-left corner attachment
Bottom-left attachment
Top-right corner attachment
Top-right attachment
Finished houses using modular designs
Finished houses — different footprints and story counts produce noticeably different shapes

Interior decoration

Because rectangles are placed in an overlapping arrangement, the internal wall geometry comes out unpredictably. Before decorating, the entire interior needs to become a single connected space. Simply clearing all interior blocks works for overlapping rectangles fails when two rectangles sit side-by-side and only share a wall — the wall stays and the interiors remain separate.

Two placement scenarios
Overlapping rectangles (left) connect automatically. Adjacent ones (right) need the wall-removal pass.

The wall-removal pass traverses every wall block and checks its neighbours. If the block's interior-facing neighbour is interior space, and at least one of its exterior-facing neighbours is also interior space, the wall is redundant and gets removed. This repeats floor by floor until the whole building is open inside.

Wall removal demonstration
Teal and white walls are removed; black walls stay because both their exterior neighbours remain exterior

Once the interior is cleared, wood flooring is laid at ground level across the whole floor plan. Decorations are then placed by scanning the edges of each interior region: a table-and-chair set (oak fence, stone pressure plate, oak stairs) goes wherever three free blocks in a row back onto a solid wall; a prismarine-and-candle decoration fills remaining two-block spots. Finally, a door is inserted in the first exterior wall position that has interior on one side and exterior on the other.

Decoration types
The two decoration types — prismarine candle arrangement (left) and table + chairs (right)
Decoration placement logic
Yellow spots qualify for the 3-block decoration; red spots don't because the adjacent wall was cleared
Example interior
Generated interior
Example interior
Another generated interior

Worship place & chandelier

The worship place uses a fixed footprint — a central 11×11 block with four 4×4 corner towers and four smaller side nubs, giving it a cross-like silhouette when viewed from above. Unlike the houses, where the footprint is random, the worship place keeps the same shape every run. What varies is the story count: each component (center and corners) independently gets a random number of stories between 1 and 4, so the overall height profile changes noticeably between runs.

Worship place footprint
The fixed footprint — center in one colour, corner towers in another
Worship place modular pieces
The modular building blocks — entrance, floor, and roof variants for center and corners
Different worship place builds
A few emergent designs — the same footprint with different story heights produces quite different buildings

Inside the hall, a chandelier is hung procedurally. From the centre 3×3 section of the ceiling, 3–7 positions are chosen at random. Each grows a column of oak fences downward to a random depth, with a shroomlight at the bottom.

Example chandelier
A generated chandelier with three chains inside the worship hall

Biome adaptation

Just before placing any structure, the system samples the Minecraft biome at the centre of that building's footprint. It then looks up a conversion table and swaps blocks accordingly before placing them — oak planks become jungle planks in a jungle biome, cobblestone becomes mossy cobblestone, sand replaces dirt in a desert, and so on.

The lookup table covers over 20 biomes: plains, taiga, jungle, cherry grove, mangrove swamp, savanna, desert, badlands, mushroom fields, crimson and warped forests, deep dark, and several others.