Skip to content
CoreSource checked

Wang Tiles

Generates tiled patterns by matching edge colors between neighboring tiles.

Quick Facts

Compact metadata for implementation and discovery.

Category
Procedural Generation
Difficulty
Intermediate
Family
Tile-Based Generation
Tier
Core
Status
Verified
Review
Source Checked
Sources
2
Formulas
0
Relationships
4
Code example
Ready
Visualization
Ready

Overview

Wang tiles assign colors or labels to tile edges and allow adjacent tiles only when touching edge labels match. This local rule can generate large nonperiodic textures, maps, or patterns from a finite tile set.

Core Concepts

nonperiodic tilingtile-based generationcolor refinementtile constraintsprocedural generation

Quick facts

Complexity

Runtime and memory behavior at a glance.

Best

O(n)

Average

O(n log n)

Worst

O(n^2)

Space

O(n)

When to Use

  • Use when local edge compatibility is enough to express the desired pattern.
  • Use when repeatable tile placement is preferable to hand-authored layouts.

When Not to Use

  • Avoid when global structure or long-range constraints matter more than local matching.
  • Avoid when the tile set does not contain enough compatible choices to avoid dead ends.

What It Does

  • Represents tile compatibility with edge labels
  • Places tiles so neighboring edge labels match
  • Builds larger patterns from local adjacency rules

Use Cases

  • Procedural textures and map patterns
  • Nonperiodic tiling from a finite tile set
  • Rule-driven content generation with local constraints

Inputs

  • 2D grid dimensions (W × H) and tile set with edge-color or motif rules
  • PRNG seed and boundary constraints

Outputs

  • Seamlessly tiled 2D grid assignment
  • Edge-matched procedural pattern or connectedness layout

Pseudocode

  1. 1.Precompute tile compatibility by edge direction
  2. 2.Choose an empty grid cell
  3. 3.List tiles compatible with already placed neighbors
  4. 4.Choose a tile using the seedable selection rule
  5. 5.Backtrack or repair if no compatible tile exists
  6. 6.Repeat until the grid is filled

Canonical Example

Input
tiles with north/east/south/west edge colors and a 3x3 grid
Output
a grid where every shared edge has matching colors
Explanation
Each placement checks only the already-filled neighboring edge labels.

Implementation Notes

  • Precompute compatible tiles for each edge label and direction.
  • Record the seed and tile-set version with generated output.
  • Validate sample outputs for repetition, dead ends, and boundary artifacts.

Common Pitfalls

  • A locally valid tile set can still create obvious repetition or dead ends.
  • Boundary rules must be defined for map edges and wrapped worlds.
  • Random tile choice without backtracking can fail late in generation.

Interactive Mechanism Walkthrough

Spatial Primitive & Sweep-Line Canvas

Show placing edge-colored tiles so neighboring colors match on a small nonperiodic tiling example.

Wang Tiles mechanism walkthrough step 1 of 6
Step 1 of 6: Precompute tile compatibility by edge direction
procedural-generation-mechanism

Notes

Wang tiling is local; additional constraints are needed for global structure.

Sources (2)

What each reference supports for this entry.

Texturing and Modeling: A Procedural Approach

Book

Procedural texturing reference for tile-based nonperiodic pattern generation.

Wang Tiles for Image and Texture Generation

Paper

Reference for stochastic Wang-tile assembly, edge-color matching, and nonperiodic texture generation.

Open source

Explore Next

Good next jumps from the relationship graph, ranked for useful discovery.

Conceptual neighborSimple Tiled Model

Both generate patterns from tile-adjacency constraints.

Conceptual neighborWave Function Collapse

Wang tile compatibility is closely related to WFC-style adjacency constraints.

Often paired withTruchet Tiles

Both are practical tile systems for procedural nonperiodic patterns.

Tags

Procedural Generation