Skip to content

Procedural Content Generation

PCG is the algorithmic creation of data with limited or no human input. In the context of tilemap generation, PCG allows for the automatic creation of varied maps by applying rules and randomness.

Overview

PCG typically employs randomness combined with deterministic algorithms to generate game content such as levels, terrains, or tilemaps. This approach is beneficial for increased replayability due to unpredictable map layouts, reduced manual effort for content creation, and dynamic content tailored to game conditions or player actions.

Example: Random Initialization

with tile

tile grass  = bit(24)
tile water  = bit(25)
tile rock   = bit(26)
tile path   = bit(30)
tile wall   = bit(31)

rows {
    1 * rock -> 20 * path
    3 * wall -> 17 * grass
}

xrows !mirror {
    4 * rock -> 4 * grass
}

Cellular Automata for Map Evolution

Acid can implement classic cellular automata (e.g., Conway's Game of Life) to evolve tile states over iterations, producing organic and unique patterns.

Example of grid based movement:

with animation

grid {
    init {
        width: 5
        height: 5
    }
    square{gridpos: 0,0}
        ->square{gridpos: 2,2}
        ->circle{gridpos: 4,4}
        ->circle{gridpos: 1,3}
        ->square{gridpos: 0,0}!
}