{
 "id": "map-elites",
 "title": "MAP-Elites (Quality-Diversity Search)",
 "aliases": [
  "illumination algorithm",
  "quality-diversity"
 ],
 "domain": "procgen",
 "subdomain": "search-based generation",
 "stage": "procedural",
 "realtime": "offline",
 "platforms": [
  "cpu",
  "python",
  "cuda"
 ],
 "year_introduced": 2015,
 "inputs": [
  "layout"
 ],
 "outputs": [
  "layout",
  "graph"
 ],
 "style": "both",
 "dynamic": "static",
 "summary": "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.",
 "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_use": "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.",
 "cost": {
  "class": "offline",
  "notes": "Thousands to millions of evaluations; cost is dominated by the evaluation function (often a simulation or render)."
 },
 "failure_modes": [
  "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"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "arxiv:1504.04909",
   "type": "paper",
   "title": "Illuminating search spaces by mapping elites",
   "authors": [
    "Jean-Baptiste Mouret",
    "Jeff Clune"
   ],
   "year": 2015,
   "venue": "arXiv preprint (cs.AI)",
   "url": "https://arxiv.org/abs/1504.04909",
   "ids": {
    "arxiv": "1504.04909"
   },
   "license": null,
   "extra": {
    "arxiv_version": "1",
    "category": "cs.AI"
   },
   "provenance": {
    "title": {
     "authority": "arxiv",
     "endpoint": "https://export.arxiv.org/api/query?id_list=1504.04909",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "arxiv",
     "endpoint": "https://export.arxiv.org/api/query?id_list=1504.04909",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "arxiv",
     "endpoint": "https://export.arxiv.org/api/query?id_list=1504.04909",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "arxiv",
     "endpoint": "https://export.arxiv.org/api/query?id_list=1504.04909",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "arxiv",
     "endpoint": "https://export.arxiv.org/api/query?id_list=1504.04909",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "mouret2015illuminating"
  },
  {
   "role": "implementation",
   "key": "gh:resibots/pymap_elites",
   "type": "code",
   "title": "resibots/pymap_elites",
   "description": "map elites python reference implementation",
   "authors": [
    "resibots"
   ],
   "year": 2019,
   "venue": "GitHub",
   "url": "https://github.com/resibots/pymap_elites",
   "ids": {
    "repo": "resibots/pymap_elites"
   },
   "license": "NOASSERTION",
   "extra": {
    "stars": 100,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2023-09-20T13:44:59Z",
    "language": "Python",
    "homepage": null,
    "license_name": "Other"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/resibots/pymap_elites",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/resibots/pymap_elites",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/resibots/pymap_elites",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/resibots/pymap_elites",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/resibots/pymap_elites",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/resibots/pymap_elites",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "resibots2019resibots"
  }
 ],
 "presets": [
  {
   "id": "map-elites-live",
   "title": "MAP-Elites (Quality-Diversity) — 5x5 behavior-descriptor archive grid (left) vs selected elite 3D morphology (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_EVO_SPEED": 0.65,
    "P_SEL_CELL_X": 0.62,
    "P_SEL_CELL_Y": 0.68,
    "P_SPLIT": 0.52
   },
   "basis": "original",
   "license_note": "MIT — written for this index.",
   "code": "const float P_EVO_SPEED = 0.65; // P Evolution Rate [0.0, 2.0, 0.05]\nconst float P_SEL_CELL_X = 0.62; // P Descriptor X (Sym) [0.0, 1.0, 0.05]\nconst float P_SEL_CELL_Y = 0.68; // P Descriptor Y (Comp) [0.0, 1.0, 0.05]\nconst float P_SPLIT = 0.52; // P Archive / Hero Split [0.0, 1.0, 0.02]\n\nfloat hash21(vec2 p) {\n  p = fract(p * vec2(127.1, 311.7));\n  p += dot(p, p + 34.5);\n  return fract(p.x * p.y);\n}\n\n// Parametric evolved 3D morphology indexed by Behavior Descriptors (bx = fold/spikiness, by = branching/hollowness)\nfloat sdMorphology(vec3 p, float bx, float by) {\n  float r = length(p);\n  float phi = atan(p.z, p.x);\n  float th = acos(clamp(p.y / max(r, 1e-4), -1.0, 1.0));\n\n  float symFreq = floor(2.0 + bx * 5.0);\n  float lobes = 0.14 * (0.2 + 0.8 * bx) * cos(phi * symFreq) * sin(th * (2.0 + floor(by * 3.0)));\n  float baseSph = r - (0.44 + lobes);\n\n  // Branching torus / ring structure controlled by descriptor Y\n  vec2 q = vec2(length(p.xz) - (0.34 + 0.16 * by), p.y);\n  float dRing = length(q) - (0.14 - 0.04 * by);\n\n  float d = mix(baseSph, min(baseSph, dRing), smoothstep(0.15, 0.85, by));\n  // Hollow core carving at high descriptor Y\n  float carve = length(p) - (0.18 + 0.16 * by);\n  d = max(d, -mix(-1.0, carve, smoothstep(0.45, 0.95, by)));\n  return d * 0.68;\n}\n\nvec3 calcMorphNormal(vec3 p, float bx, float by) {\n  vec2 e = vec2(0.0035, 0.0);\n  return normalize(vec3(\n    sdMorphology(p + e.xyy, bx, by) - sdMorphology(p - e.xyy, bx, by),\n    sdMorphology(p + e.yxy, bx, by) - sdMorphology(p - e.yxy, bx, by),\n    sdMorphology(p + e.yyx, bx, by) - sdMorphology(p - e.yyx, bx, by)\n  ));\n}\n\n// Evaluate fitness score for a cell (bx, by) growing over evolutionary generations\nfloat evalCellFitness(vec2 cellId, float evoT) {\n  float bx = (cellId.x + 0.5) / 5.0;\n  float by = (cellId.y + 0.5) / 5.0;\n  float seed = hash21(cellId * 13.7 + 2.1);\n  // Multi-modal quality landscape across behavior space\n  float peak = 0.42 + 0.34 * sin(bx * 4.2 + 0.6) * cos(by * 3.8 - 0.4) + 0.24 * seed;\n  float wave = smoothstep(0.0, 1.0, fract(evoT * 0.18 + seed * 0.7));\n  return clamp(peak * (0.68 + 0.32 * wave), 0.15, 1.0);\n}\n\nvec3 viridis(float t) {\n  t = clamp(t, 0.0, 1.0);\n  vec3 c0 = vec3(0.18, 0.08, 0.36);\n  vec3 c1 = vec3(0.12, 0.54, 0.56);\n  vec3 c2 = vec3(0.96, 0.86, 0.20);\n  if (t < 0.5) return mix(c0, c1, t * 2.0);\n  return mix(c1, c2, (t - 0.5) * 2.0);\n}\n\nvec3 aces(vec3 x) {\n  x = max(x, 0.0);\n  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  float sx = fragCoord.x / max(iResolution.x, 1.0);\n  float split = clamp(P_SPLIT, 0.0, 1.0);\n  bool showHero = sx >= split;\n\n  float evoT = iTime * max(P_EVO_SPEED, 0.0);\n  float selX = clamp(P_SEL_CELL_X, 0.0, 0.999);\n  float selY = clamp(P_SEL_CELL_Y, 0.0, 0.999);\n  vec2 selCell = floor(vec2(selX, selY) * 5.0);\n  // Animated evolutionary mutation cursor jumping across archive cells\n  float mutIdx = mod(floor(evoT * 1.4), 25.0);\n  vec2 mutCell = vec2(mod(mutIdx, 5.0), floor(mutIdx / 5.0));\n\n  vec3 col = vec3(0.04, 0.05, 0.08);\n\n  if (!showHero) {\n    // Left: 5x5 MAP-Elites Quality-Diversity Archive Illumination Grid!\n    vec2 p = vec2(sx / max(split, 0.05), fragCoord.y / max(iResolution.y, 1.0));\n    vec2 g = (p - vec2(0.06, 0.08)) / vec2(0.88, 0.84);\n    if (g.x >= 0.0 && g.x < 1.0 && g.y >= 0.0 && g.y < 1.0) {\n      vec2 cellId = floor(g * 5.0);\n      vec2 f = fract(g * 5.0);\n      float bx = (cellId.x + 0.5) / 5.0;\n      float by = (cellId.y + 0.5) / 5.0;\n      float fit = evalCellFitness(cellId, evoT);\n      vec3 fitCol = viridis(fit);\n\n      // Cell background shaded by elite fitness score\n      col = fitCol * 0.24;\n\n      // Mini 3D raymarched specimen inside each archive cell\n      vec2 cuv = (f - 0.5) * 2.1;\n      float a = iTime * 0.5 + cellId.x * 0.7 + cellId.y * 0.5;\n      mat3 rot = mat3(cos(a), 0.0, sin(a), 0.0, 1.0, 0.0, -sin(a), 0.0, cos(a));\n      vec3 ro = vec3(0.0, 0.25, 1.75);\n      vec3 rd = normalize(vec3(cuv, -1.75));\n      float t = 0.4;\n      for (int i = 0; i < 22; i++) {\n        vec3 mp = rot * (ro + rd * t);\n        float d = sdMorphology(mp, bx, by);\n        if (d < 0.012) {\n          vec3 n = normalize(transpose(rot) * calcMorphNormal(mp, bx, by));\n          float nl = max(dot(n, normalize(vec3(0.6, 0.8, 0.5))), 0.12);\n          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;\n          break;\n        }\n        t += d;\n        if (t > 2.8) break;\n      }\n\n      // Bottom fitness bar inside each cell\n      if (f.y < 0.09 && f.x > 0.08 && f.x < 0.08 + 0.84 * fit) {\n        col = fitCol * 1.25;\n      }\n\n      // Grid divider & highlight borders for Selected Elite (white/gold) and Active Mutation Probe (cyan)\n      float border = smoothstep(0.045, 0.015, min(min(f.x, 1.0 - f.x), min(f.y, 1.0 - f.y)));\n      vec3 bCol = vec3(0.14, 0.18, 0.24);\n      if (all(equal(cellId, selCell))) bCol = vec3(1.0, 0.84, 0.22) * 1.4;\n      else if (all(equal(cellId, mutCell))) bCol = vec3(0.22, 0.95, 1.0) * 1.3;\n      col = mix(col, bCol, border);\n    }\n  } else {\n    // Right: Full-resolution 3D studio hero inspection of the selected archive elite!\n    float bx = (selCell.x + 0.5) / 5.0;\n    float by = (selCell.y + 0.5) / 5.0;\n    float fit = evalCellFitness(selCell, evoT);\n    vec3 fitCol = viridis(fit);\n\n    float a = iTime * 0.48;\n    mat3 rot = mat3(cos(a), 0.0, sin(a), 0.0, 1.0, 0.0, -sin(a), 0.0, cos(a));\n    vec3 ro = vec3(0.0, 0.28, 1.95);\n    vec3 rd = normalize(vec3(uv - vec2(0.18, 0.0), -1.45));\n    col = mix(vec3(0.05, 0.06, 0.09), vec3(0.14, 0.18, 0.26), uv.y + 0.5);\n\n    float t = 0.05;\n    bool hit = false;\n    for (int i = 0; i < 64; i++) {\n      vec3 mp = rot * (ro + rd * t);\n      float d = sdMorphology(mp, bx, by);\n      if (d < 0.002) { hit = true; break; }\n      t += d;\n      if (t > 5.5) break;\n    }\n\n    if (hit) {\n      vec3 mp = rot * (ro + rd * t);\n      vec3 n = normalize(transpose(rot) * calcMorphNormal(mp, bx, by));\n      vec3 v = -rd;\n      vec3 L1 = normalize(vec3(0.65, 0.78, 0.52));\n      vec3 L2 = normalize(vec3(-0.7, -0.2, 0.55));\n      vec3 H = normalize(L1 + v);\n      float ndl1 = max(dot(n, L1), 0.0);\n      float ndl2 = max(dot(n, L2), 0.0);\n      float spec = pow(max(dot(n, H), 0.0), 42.0);\n      float rim = pow(1.0 - max(dot(n, v), 0.0), 3.0);\n      col = fitCol * (1.28 * ndl1 + 0.35 * ndl2 + 0.20) + vec3(1.0, 0.95, 0.88) * spec * 0.85 + fitCol * rim * 0.55;\n    }\n  }\n\n  float sep = smoothstep(0.0035, 0.0008, abs(sx - split));\n  col = mix(col, vec3(0.95, 0.97, 1.0), sep);\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "map-elites",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T21:07:15.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.4051,
      "std": 0.1236,
      "min": 0.2424,
      "max": 0.9266
     },
     "image": "/specimens/map-elites-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "wave-function-collapse",
  "infinigen",
  "bsp-dungeon-generation"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "bsp-dungeon-generation",
   "why": "Dungeon parameters are evolved and the map archives layouts by descriptors like room count and loop count."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/procgen/map-elites.json"
 },
 "solves": [
  "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"
 ],
 "authority": "Mouret & Clune, 2015",
 "url": "https://texelatlas.vercel.app/t/map-elites/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 14.06,
  "tier": "moderate",
  "p50_ms": 0.4625,
  "p95_ms": 0.479,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 32,
  "preset_id": "map-elites-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 13.66,
   "tier": "moderate",
   "p50_ms": 0.2172,
   "p95_ms": 0.2233,
   "speedup_x": 2.13,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 9.59,
   "tier": "moderate",
   "p50_ms": 0.2761,
   "p95_ms": 0.2795,
   "speedup_x": 1.68,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}