{"slug": "why-naive-syllable-concatenation-produces-unpronounceable-rpg-names-and-how-fix", "title": "Why Naive Syllable Concatenation Produces Unpronounceable RPG Names (And How Phonotactic Weights Fix Them)", "summary": "A developer built a compact TypeScript procedural name generator that replaces flat syllable arrays with a weighted phonotactic transition table, vowel-harmony constraints, and a deduplication pass to avoid unpronounceable RPG names. The engine scores each root-suffix join by coda-to-onset boundary legality and front/back harmony, zeroing out illegal clusters like stop-to-stop and fricative-to-fricative collisions without needing an LLM at runtime.", "body_md": "Most procedural RPG name generators start the same way: three arrays of syllables—prefixes, middles, and suffixes—joined with `Math.random()`. On paper, 40 prefixes × 30 middles × 40 suffixes yields 48,000 combinations. In practice, roughly half of them look like `kthrg'vl`, `bztl'k`, or `aeouia`. Players stumble over them on voice chat, and tabletop GMs end up renaming the NPC \"Bob\" two minutes into the session.\n\nThe root cause is structural. Random concatenation treats syllables as independent tokens, ignoring [phonotactics](https://en.wikipedia.org/wiki/Phonotactics)—the rules governing which phoneme sequences a language permits at syllable boundaries. When a prefix ends in a stop cluster (`-kt`) and the next syllable starts with a fricative cluster (` thr-`), the boundary creates an illegal five-consonant pileup.\n\nReplacing flat arrays with a weighted transition table, a vowel-harmony constraint, and a lightweight deduplication layer fixes the output without needing an LLM at runtime.\n\nUniform sampling breaks down along three predictable axes:\n\n`r`, `n`, or `l` transitions cleanly into `t`, `d`, or `s`, whereas a coda ending in `k` or `g` colliding with an onset like `vr-` or `zh-` forces an unnatural glottal stop.`ae-` + `-ia-` + `-eo`) creates diphthongs with no rhythmic anchor, making stress placement ambiguous.\nTools that focus on lore-grounded character naming—such as [Fantasy Name Generator](https://fantasynamegenerator.art/)—solve this by separating phoneme inventories per culture and pairing phonological structure with semantic roots rather than relying on blind string joins.\n\nInstead of storing raw syllable strings in flat arrays, represent each morpheme with its **phonetic class**, **coda/onset tags**, **vowel harmony group** (`front` vs. `back`), and optional **semantic gloss**. A compact 40-line TypeScript engine can enforce legal transitions deterministically:\n\n```\ntype Harmony = \"front\" | \"back\";\ntype Boundary = \"vowel\" | \"liquid\" | \"nasal\" | \"stop\" | \"fricative\";\n\ninterface Morpheme {\n  text: string;\n  gloss: string;\n  harmony: Harmony;\n  onset: Boundary;\n  coda: Boundary;\n  weight: number;\n}\n\n// Allowed coda -> onset transitions (0 = forbidden)\nconst TRANSITION_WEIGHT: Record<Boundary, Record<Boundary, number>> = {\n  vowel:     { vowel: 0.1, liquid: 1.0, nasal: 1.0, stop: 0.9, fricative: 0.8 },\n  liquid:    { vowel: 1.0, liquid: 0.15, nasal: 0.6, stop: 0.7, fricative: 0.5 },\n  nasal:     { vowel: 1.0, liquid: 0.4, nasal: 0.1, stop: 0.8, fricative: 0.5 },\n  stop:      { vowel: 1.0, liquid: 0.5, nasal: 0.2, stop: 0.0, fricative: 0.1 },\n  fricative: { vowel: 1.0, liquid: 0.4, nasal: 0.3, stop: 0.2, fricative: 0.0 },\n};\n\nfunction pickWeighted<T>(items: Array<{ item: T; score: number }>, rng: () => number): T {\n  const total = items.reduce((sum, x) => sum + x.score, 0);\n  let r = rng() * total;\n  for (const entry of items) {\n    r -= entry.score;\n    if (r <= 0) return entry.item;\n  }\n  return items[items.length - 1].item;\n}\n\nexport function buildName(\n  roots: Morpheme[],\n  suffixes: Morpheme[],\n  rng: () => number = Math.random\n): { name: string; meaning: string } {\n  const root = pickWeighted(roots.map((m) => ({ item: m, score: m.weight })), rng);\n\n  const scoredSuffixes = suffixes\n    .map((suf) => {\n      const boundaryScore = TRANSITION_WEIGHT[root.coda][suf.onset];\n      const harmonyBonus = root.harmony === suf.harmony ? 1.0 : 0.25;\n      return { item: suf, score: suf.weight * boundaryScore * harmonyBonus };\n    })\n    .filter((x) => x.score > 0);\n\n  const suffix = pickWeighted(scoredSuffixes, rng);\n  const raw = `${root.text}${suffix.text}`.replace(/(.)\\1\\1+/g, \"$1$1\");\n  return {\n    name: raw.charAt(0).toUpperCase() + raw.slice(1),\n    meaning: `${root.gloss} + ${suffix.gloss}`,\n  };\n}\n```\n\nThree details do most of the heavy lifting here:\n\n`stop -> stop` and `fricative -> fricative`` kt-`, `gd-`, `sz-`, and `fv-` collisions at the join point.`1.0` vs `0.25`)` e`, `i`, `ae`) naturally pair with front-vowel suffixes, while back vowels (`a`, `o`, `u`) pull back-vowel endings. Keeping a 0.25 fallback prevents the pool from feeling repetitive.`/(.)\\1\\1+/g`)` ll`).\nWhen designing multiple elven cultures in the same game world, you do not need separate codebases—just distinct phoneme tables mapped against the [International Phonetic Alphabet (IPA)](https://en.wikipedia.org/wiki/International_Phonetic_Alphabet). Even within a single species, shifting liquid/nasal ratios and syllable counts produces immediately recognizable families:\n\n| Design Axis | Moonlight / Woodland Elven | Solar / Astral High-Born Elven | \n|---|---|---|\n| **Core Onsets** | Soft stops & nasals ( `/m/` ,`/n/` ,`/t/` ,`/ʃ/` ) | Liquids & sibilants ( `/l/` ,`/r/` ,`/s/` ,`/v/` ) | \n| **Dominant Vowels** | Balanced short/long ( `/a/` ,`/i/` ,`/u/` ,`/o/` ) | Front & diphthong-heavy ( `/eː/` ,`/iː/` ,`/aɪ/` ,`ae` ) | \n| **Syllable Target** | 2–3 syllables given name + compound surname | 3–4 syllables given name + patronymic or house affix | \n| **Semantic Roots** | Moon, owl, shadow, grove, whisper, tide | Dawn, star, crown, spire, crystal, flame | \n| **Example Structure** | `Syl-` +`-varis` →*Sylvaris* ,`Lyr-` +`-eth` →*Lyreth* | `Ael-` +`-arion` →*Aelarion* ,`Cal-` +`-endil` →*Calendil* | \n\nTraditional Elder Scrolls lore documented in the [UESP Altmer naming documentation](https://en.uesp.net/wiki/Lore:Altmer_Names) illustrates this solar/high-born pattern clearly: multi-syllabic stems with open vowels and crisp liquid codas (`-il`, `-or`, `-ion`) signal antiquity and formal register. If you want to inspect how meaning-tagged high-born elven roots combine across different syllable weights in a live tool, [Fantasy Name Generator's High Elf name generator](https://fantasynamegenerator.art/high-elf-name-generator/) exposes the semantic breakdown alongside each generated name.\n\nChecking `seen.has(name)` is not enough. If a batch outputs `Aelarion`, `Aelaryon`, and `Aelarien` in the same ten-item roll, players perceive them as duplicates even though all three are distinct strings.\n\nA fast, zero-dependency deduplication filter combines three checks:\n\n`y -> i`, `ph -> f`, `c -> k`. Both `Aelarion` and `Aelaryon` hash to `ALRN`, blocking near-homophones in the same batch.` distance >= 3`)\n\n``` js\nfunction phoneticKey(name: string): string {\n  const lower = name.toLowerCase().replace(/[^a-z]/g, \"\");\n  if (!lower) return \"\";\n  const head = lower[0];\n  const tail = lower\n    .slice(1)\n    .replace(/ph/g, \"f\")\n    .replace(/[cy]/g, (ch) => (ch === \"c\" ? \"k\" : \"i\"))\n    .replace(/[aeiou]/g, \"\")\n    .replace(/(.)\\1+/g, \"$1\");\n  return head + tail;\n}\n```\n\nRun a 1,000-sample smoke test before shipping and assert four metrics:\n\nPhonotactic weights take under 100 lines of TypeScript, run in microseconds on the client, and eliminate the gibberish that breaks immersion.", "url": "https://wpnews.pro/news/why-naive-syllable-concatenation-produces-unpronounceable-rpg-names-and-how-fix", "canonical_source": "https://dev.to/gaven/why-naive-syllable-concatenation-produces-unpronounceable-rpg-names-and-how-phonotactic-weights-5e8l", "published_at": "2026-11-27 05:10:26+00:00", "updated_at": "2026-11-27 05:14:25.759474+00:00", "lang": "en", "topics": ["generative-ai", "developer-tools"], "entities": ["Fantasy Name Generator", "TypeScript"], "also_reported_by": [], "takeaway": "Scoring syllable joins with a coda-to-onset transition table (stop-to-stop and fricative-to-fricative weighted 0.0) plus a 1.0/0.25 vowel-harmony bonus eliminates illegal consonant pileups without an LLM at runtime.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/why-naive-syllable-concatenation-produces-unpronounceable-rpg-names-and-how-fix", "markdown": "https://wpnews.pro/news/why-naive-syllable-concatenation-produces-unpronounceable-rpg-names-and-how-fix.md", "text": "https://wpnews.pro/news/why-naive-syllable-concatenation-produces-unpronounceable-rpg-names-and-how-fix.txt", "jsonld": "https://wpnews.pro/news/why-naive-syllable-concatenation-produces-unpronounceable-rpg-names-and-how-fix.jsonld"}}