Procedural content generation is one of the most powerful tools in a 2D game developer’s toolkit — and one of the most frequently misapplied. The promise of “infinite content” is seductive, but the reality is that procedural generation produces infinite variation, which is different from infinite quality. Understanding that distinction is what separates games with compelling randomised content from games that feel like they were assembled by an algorithm.

At Relish Games, we’ve worked with procedural techniques in both game content and tooling contexts. This is our practical guide to what works, what doesn’t, and where the tradeoffs live.

Dungeon and Level Generation

The most common application of PCG in 2D games, and the one with the most established approaches.

Binary Space Partition (BSP)

BSP recursively divides a rectangular space into smaller rooms, then connects them with corridors.

How it works: Start with the full map area. Split it vertically or horizontally at a random point. Recursively split each half until rooms reach minimum size. Place rooms within each partition, then connect adjacent partitions with corridors.

Strengths: Guarantees non-overlapping rooms. Produces clean, grid-friendly layouts. Easy to ensure connectivity.

Weaknesses: Rooms tend to feel regular and boxy. Corridor placement can look artificial. Less organic than other methods.

Random Walk (Drunkard’s Walk)

A simple approach: start at a point and randomly walk, carving out floor tiles as you go.

How it works: Place a walker at the map centre. Each step, move in a random direction and mark the tile as floor. Repeat for N steps or until a target percentage of the map is open.

Strengths: Produces organic, cave-like layouts. Very simple to implement. Natural-looking results.

Weaknesses: No room structure. Can produce narrow, snaking paths. Hard to control specific layout properties.

Cellular Automata

Inspired by Conway’s Game of Life, this approach generates natural cave systems.

How it works: Start with random noise (each tile has a ~45% chance of being a wall). Apply smoothing rules: a tile becomes a wall if most of its neighbours are walls, and vice versa. Repeat for 4–6 iterations.

Strengths: Produces the most natural-looking cave environments. Parameters are intuitive to tune. Works at any scale.

Weaknesses: Can produce disconnected regions (requires post-processing to connect). Less suitable for structured room-and-corridor layouts.

Hybrid Approaches

The best results often come from combining methods:

  1. Use BSP to define room positions and sizes
  2. Use cellular automata to shape room interiors organically
  3. Use A* pathfinding to carve interesting corridors between rooms
  4. Apply post-processing rules for gameplay-critical features (spawn points, item placement, exits)

This layered approach gives you the structural reliability of BSP with the visual naturalness of cellular automata.

Terrain Generation for Side-Scrollers

For side-scrolling games, terrain generation operates differently:

Height Map Approaches

Generate a one-dimensional height map using Perlin noise or similar functions. The height at each X position determines the ground level.

Key considerations:

  • Layer multiple frequencies for natural-looking terrain (low frequency for hills, high frequency for surface detail)
  • Ensure platformable gaps by clamping maximum height differences between adjacent columns
  • Place platforms, ledges, and gaps based on difficulty curves rather than pure randomness

Chunk-Based Generation

Pre-design small terrain chunks (16–32 tiles wide) and assemble them procedurally. Each chunk has defined entry/exit points and difficulty ratings.

Advantages: Each chunk is hand-tested for playability. Assembly is fast and reliable. Difficulty can be controlled precisely.

Disadvantages: Players eventually recognise chunks. Requires designing dozens of chunks for variety.

Procedural Item and Loot Generation

Generating items — weapons, armour, power-ups — procedurally can add variety without designing each item individually.

The Template Approach

Define templates with variable properties:

Sword Template:
  Base damage: 10–25
  Speed: Fast / Medium / Slow
  Element: None / Fire / Ice / Lightning (weighted random)
  Modifier: +damage / +speed / +critical (0–2 modifiers)
  Rarity: Common (60%) / Uncommon (25%) / Rare (12%) / Epic (3%)

The template constrains the design space so every generated item is functional. Random rolls within templates produce variation.

Balance Through Constraints

The danger of procedural items is power creep and nonsensical combinations. Constraints prevent this:

  • Budget systems: Each item has a “power budget.” More damage means less speed.
  • Rarity gating: Higher rarity unlocks more modifier slots but not more base power
  • Synergy rules: Certain modifier combinations are blocked or forced for coherence

As we discussed in our piece on data-driven game design, analytics can reveal when your procedural generation produces unbalanced outliers that actual players encounter.

Seed-Based Generation

Using deterministic seeds for procedural generation enables several powerful features:

  • Shareable runs: Players can share a seed number to play the same generated content
  • Bug reproduction: QA can reproduce exact procedural layouts by recording the seed
  • Daily challenges: The same seed for all players creates a shared competitive experience
  • Streaming-friendly: Viewers can try the same seed they watched someone play

Implementation: use a seeded pseudorandom number generator (PRNG) rather than system random. Every procedural decision should draw from the seeded PRNG in a deterministic order.

The critical requirement: the generation process must be fully deterministic. Any non-deterministic input (system time, floating-point inconsistencies, unordered data structures) will break seed reproducibility.

Balancing Handcraft and Procedural Content

The most successful procedurally generated games don’t rely on PCG alone:

The Handcrafted Anchor Points

  • Tutorial areas: Always hand-designed for clarity
  • Boss arenas: Too gameplay-critical for procedural layout
  • Story moments: Narrative beats need precise environmental control
  • First impressions: The opening minutes should be curated

The Procedural Fill

  • Exploration areas between anchors: PCG provides variety in traversal
  • Side content and optional paths: Procedural rewards for curiosity
  • Enemy placement and composition: Varied encounters within hand-tuned difficulty curves
  • Loot and item distribution: Procedural drops keep rewards unpredictable

As we explored in building dynamic NPCs with AI, the same principle applies: handcrafted rules create the structure, and randomisation provides the variation within that structure.

Testing Procedural Content at Scale

You can’t manually play every possible generation. But you can validate them:

Automated Validation

Write tests that generate thousands of levels and verify:

  • All rooms are reachable from the start
  • At least one valid path exists from start to exit
  • No areas exceed maximum difficulty bounds
  • Item distribution meets statistical targets
  • No hard-lock states exist

Statistical Analysis

Generate 10,000 levels and analyse distributions:

  • Average and standard deviation of room count, path length, enemy density
  • Frequency of specific feature combinations
  • Outlier detection for unusually easy or impossible layouts

Focused Playtesting

Generate levels with extreme seeds (very high, very low, prime numbers, zero) and playtest those specifically. Edge cases in the random distribution often produce edge cases in gameplay.

What We’d Do in Practice

For a 2D roguelite or procedurally-augmented game:

  1. Start with BSP or chunk-based generation — reliable and testable
  2. Add organic flavour with cellular automata or noise-based detail
  3. Hand-design all critical encounters — bosses, shops, story beats
  4. Use seed-based generation from day one — the debugging benefits alone are worth it
  5. Build automated validators early — they pay for themselves immediately
  6. Tune through analytics — track what players actually experience, not what the generator theoretically produces

The goal isn’t to generate everything procedurally. It’s to generate the right things procedurally, so your limited handcraft time goes toward the moments that matter most.

Explore how game systems work in practice through the HGE documentation, or discuss PCG strategies in our forum.