MAP-Elites (Quality-Diversity Search)
An evolutionary algorithm that fills a grid defined by chosen behaviour descriptors with the best-performing solution found for each cell, producing a diverse archive of high-quality content instead of a single optimum.
Also known as illumination algorithm, quality-diversity
In the family Procedural generation, search-based generation
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | None found | No built-in MAP-Elites quality-diversity evolutionary search framework. |
| Unity | None found | |
| Unreal 5.7 | None found | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
The designer picks a fitness function (how good is this content) and a few behaviour descriptors (such as room count, symmetry, height, density) that discretise into a grid, the 'map'. Initialise the map with random candidates. Then repeat: pick a random occupied cell, mutate or recombine its elite to create a child, evaluate fitness and descriptors, and place the child in the matching cell if that cell is empty or the child has higher fitness. After many iterations the map shows, for each descriptor combination, the best content found, and the designer can browse it to choose levels, terrains or models along each axis. Variants (CVT-MAP-Elites, CMA-ME) handle higher descriptor dimensions and better exploration.
When to choose it
Reach for it when
- want many diverse good variants not one optimum
- generated levels all look alike
- explore content along axes like size and difficulty
- need an archive of high-quality varied designs
Choose it for content generation where you want a diverse set of valid, high-scoring variants along interpretable axes (dungeons of different sizes and difficulty, terrain styles, parametric shapes). Prefer a single-objective optimiser when you need exactly one optimum, and a constraint solver like Wave Function Collapse when the aim is satisfying local rules rather than scoring.
Field marks
- Descriptors that do not correlate with meaningful variation fill the map with near-duplicates
- Descriptor grid dimension explodes: more than about 3 axes needs CVT-style tessellation
- Fitness landscape deception: elites in one cell are only reachable through low-fitness cells, so coverage stalls
- Heavy dependence on mutation operator design; bad operators fill the map with invalid content
Presets
MAP-Elites (Quality-Diversity) — 5x5 behavior-descriptor archive grid (left) vs selected elite 3D morphology (right)
{
"P_EVO_SPEED": 0.65,
"P_SEL_CELL_X": 0.62,
"P_SEL_CELL_Y": 0.68,
"P_SPLIT": 0.52
}Show GLSL (171 lines)
const float P_EVO_SPEED = 0.65; // P Evolution Rate [0.0, 2.0, 0.05]
const float P_SEL_CELL_X = 0.62; // P Descriptor X (Sym) [0.0, 1.0, 0.05]
const float P_SEL_CELL_Y = 0.68; // P Descriptor Y (Comp) [0.0, 1.0, 0.05]
const float P_SPLIT = 0.52; // P Archive / Hero Split [0.0, 1.0, 0.02]
float hash21(vec2 p) {
p = fract(p * vec2(127.1, 311.7));
p += dot(p, p + 34.5);
return fract(p.x * p.y);
}
// Parametric evolved 3D morphology indexed by Behavior Descriptors (bx = fold/spikiness, by = branching/hollowness)
float sdMorphology(vec3 p, float bx, float by) {
float r = length(p);
float phi = atan(p.z, p.x);
float th = acos(clamp(p.y / max(r, 1e-4), -1.0, 1.0));
float symFreq = floor(2.0 + bx * 5.0);
float lobes = 0.14 * (0.2 + 0.8 * bx) * cos(phi * symFreq) * sin(th * (2.0 + floor(by * 3.0)));
float baseSph = r - (0.44 + lobes);
// Branching torus / ring structure controlled by descriptor Y
vec2 q = vec2(length(p.xz) - (0.34 + 0.16 * by), p.y);
float dRing = length(q) - (0.14 - 0.04 * by);
float d = mix(baseSph, min(baseSph, dRing), smoothstep(0.15, 0.85, by));
// Hollow core carving at high descriptor Y
float carve = length(p) - (0.18 + 0.16 * by);
d = max(d, -mix(-1.0, carve, smoothstep(0.45, 0.95, by)));
return d * 0.68;
}
vec3 calcMorphNormal(vec3 p, float bx, float by) {
vec2 e = vec2(0.0035, 0.0);
return normalize(vec3(
sdMorphology(p + e.xyy, bx, by) - sdMorphology(p - e.xyy, bx, by),
sdMorphology(p + e.yxy, bx, by) - sdMorphology(p - e.yxy, bx, by),
sdMorphology(p + e.yyx, bx, by) - sdMorphology(p - e.yyx, bx, by)
));
}
// Evaluate fitness score for a cell (bx, by) growing over evolutionary generations
float evalCellFitness(vec2 cellId, float evoT) {
float bx = (cellId.x + 0.5) / 5.0;
float by = (cellId.y + 0.5) / 5.0;
float seed = hash21(cellId * 13.7 + 2.1);
// Multi-modal quality landscape across behavior space
float peak = 0.42 + 0.34 * sin(bx * 4.2 + 0.6) * cos(by * 3.8 - 0.4) + 0.24 * seed;
float wave = smoothstep(0.0, 1.0, fract(evoT * 0.18 + seed * 0.7));
return clamp(peak * (0.68 + 0.32 * wave), 0.15, 1.0);
}
vec3 viridis(float t) {
t = clamp(t, 0.0, 1.0);
vec3 c0 = vec3(0.18, 0.08, 0.36);
vec3 c1 = vec3(0.12, 0.54, 0.56);
vec3 c2 = vec3(0.96, 0.86, 0.20);
if (t < 0.5) return mix(c0, c1, t * 2.0);
return mix(c1, c2, (t - 0.5) * 2.0);
}
vec3 aces(vec3 x) {
x = max(x, 0.0);
return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
float sx = fragCoord.x / max(iResolution.x, 1.0);
float split = clamp(P_SPLIT, 0.0, 1.0);
bool showHero = sx >= split;
float evoT = iTime * max(P_EVO_SPEED, 0.0);
float selX = clamp(P_SEL_CELL_X, 0.0, 0.999);
float selY = clamp(P_SEL_CELL_Y, 0.0, 0.999);
vec2 selCell = floor(vec2(selX, selY) * 5.0);
// Animated evolutionary mutation cursor jumping across archive cells
float mutIdx = mod(floor(evoT * 1.4), 25.0);
vec2 mutCell = vec2(mod(mutIdx, 5.0), floor(mutIdx / 5.0));
vec3 col = vec3(0.04, 0.05, 0.08);
if (!showHero) {
// Left: 5x5 MAP-Elites Quality-Diversity Archive Illumination Grid!
vec2 p = vec2(sx / max(split, 0.05), fragCoord.y / max(iResolution.y, 1.0));
vec2 g = (p - vec2(0.06, 0.08)) / vec2(0.88, 0.84);
if (g.x >= 0.0 && g.x < 1.0 && g.y >= 0.0 && g.y < 1.0) {
vec2 cellId = floor(g * 5.0);
vec2 f = fract(g * 5.0);
float bx = (cellId.x + 0.5) / 5.0;
float by = (cellId.y + 0.5) / 5.0;
float fit = evalCellFitness(cellId, evoT);
vec3 fitCol = viridis(fit);
// Cell background shaded by elite fitness score
col = fitCol * 0.24;
// Mini 3D raymarched specimen inside each archive cell
vec2 cuv = (f - 0.5) * 2.1;
float a = iTime * 0.5 + cellId.x * 0.7 + cellId.y * 0.5;
mat3 rot = mat3(cos(a), 0.0, sin(a), 0.0, 1.0, 0.0, -sin(a), 0.0, cos(a));
vec3 ro = vec3(0.0, 0.25, 1.75);
vec3 rd = normalize(vec3(cuv, -1.75));
float t = 0.4;
for (int i = 0; i < 22; i++) {
vec3 mp = rot * (ro + rd * t);
float d = sdMorphology(mp, bx, by);
if (d < 0.012) {
vec3 n = normalize(transpose(rot) * calcMorphNormal(mp, bx, by));
float nl = max(dot(n, normalize(vec3(0.6, 0.8, 0.5))), 0.12);
col = fitCol * (0.35 + 1.15 * nl) + vec3(0.85) * pow(max(dot(n, normalize(vec3(0.3, 0.6, 0.8))), 0.0), 20.0) * 0.4;
break;
}
t += d;
if (t > 2.8) break;
}
// Bottom fitness bar inside each cell
if (f.y < 0.09 && f.x > 0.08 && f.x < 0.08 + 0.84 * fit) {
col = fitCol * 1.25;
}
// Grid divider & highlight borders for Selected Elite (white/gold) and Active Mutation Probe (cyan)
float border = smoothstep(0.045, 0.015, min(min(f.x, 1.0 - f.x), min(f.y, 1.0 - f.y)));
vec3 bCol = vec3(0.14, 0.18, 0.24);
if (all(equal(cellId, selCell))) bCol = vec3(1.0, 0.84, 0.22) * 1.4;
else if (all(equal(cellId, mutCell))) bCol = vec3(0.22, 0.95, 1.0) * 1.3;
col = mix(col, bCol, border);
}
} else {
// Right: Full-resolution 3D studio hero inspection of the selected archive elite!
float bx = (selCell.x + 0.5) / 5.0;
float by = (selCell.y + 0.5) / 5.0;
float fit = evalCellFitness(selCell, evoT);
vec3 fitCol = viridis(fit);
float a = iTime * 0.48;
mat3 rot = mat3(cos(a), 0.0, sin(a), 0.0, 1.0, 0.0, -sin(a), 0.0, cos(a));
vec3 ro = vec3(0.0, 0.28, 1.95);
vec3 rd = normalize(vec3(uv - vec2(0.18, 0.0), -1.45));
col = mix(vec3(0.05, 0.06, 0.09), vec3(0.14, 0.18, 0.26), uv.y + 0.5);
float t = 0.05;
bool hit = false;
for (int i = 0; i < 64; i++) {
vec3 mp = rot * (ro + rd * t);
float d = sdMorphology(mp, bx, by);
if (d < 0.002) { hit = true; break; }
t += d;
if (t > 5.5) break;
}
if (hit) {
vec3 mp = rot * (ro + rd * t);
vec3 n = normalize(transpose(rot) * calcMorphNormal(mp, bx, by));
vec3 v = -rd;
vec3 L1 = normalize(vec3(0.65, 0.78, 0.52));
vec3 L2 = normalize(vec3(-0.7, -0.2, 0.55));
vec3 H = normalize(L1 + v);
float ndl1 = max(dot(n, L1), 0.0);
float ndl2 = max(dot(n, L2), 0.0);
float spec = pow(max(dot(n, H), 0.0), 42.0);
float rim = pow(1.0 - max(dot(n, v), 0.0), 3.0);
col = fitCol * (1.28 * ndl1 + 0.35 * ndl2 + 0.20) + vec3(1.0, 0.95, 0.88) * spec * 0.85 + fitCol * rim * 0.55;
}
}
float sep = smoothstep(0.0035, 0.0008, abs(sx - split));
col = mix(col, vec3(0.95, 0.97, 1.0), sep);
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: MIT — written for this index.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| map-elites-live | Tesla T4 1920x1080 | 14.1× baseline (moderate) · 0.463 ms / 0.479 ms | opengl-timer-query · 32 frames · GPU Weight Atlas · Colab T4 sweep |
| map-elites-live | NVIDIA L4 1920x1080 | 13.7× baseline (moderate) · 0.217 ms / 0.223 ms · 2.1× faster on L4 | opengl-timer-query · Cross-architecture validation |
| map-elites-live | NVIDIA A100-SXM4-40GB 1920x1080 | 9.59× baseline (moderate) · 0.276 ms / 0.280 ms · 1.7× faster on A100 | opengl-timer-query · Cross-architecture validation |
Crosses
- BSP Dungeon Generation: Dungeon parameters are evolved and the map archives layouts by descriptors like room count and loop count.
Sources
- primaryJean-Baptiste Mouret, Jeff Clune (2015). Illuminating search spaces by mapping elites. arXiv preprint (cs.AI).Verified via arxiv · 2026-11-29arXiv:1504.04909
- implementationresibots (2019). resibots/pymap_elites. map elites python reference implementationGitHub API · license NOASSERTION · 2026-11-29