DEV Community

Gaven
Gaven

Posted on

Why Naive Syllable Concatenation Produces Unpronounceable RPG Names (And How Phonotactic Weights Fix Them)

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.

The root cause is structural. Random concatenation treats syllables as independent tokens, ignoring 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.

Replacing 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.

1. Why Flat Syllable Pools Fail

Uniform sampling breaks down along three predictable axes:

  1. Boundary consonant collisions: A coda ending in 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.
  2. Vowel-weight drift: Concatenating three vowel-heavy chunks (ae- + -ia- + -eo) creates diphthongs with no rhythmic anchor, making stress placement ambiguous.
  3. Zero cultural separation: Pulling from one generic "fantasy" pool makes a forest scout sound identical to an imperial court mage.

Tools that focus on lore-grounded character naming—such as Fantasy Name Generator—solve this by separating phoneme inventories per culture and pairing phonological structure with semantic roots rather than relying on blind string joins.

2. Phonotactic Transition Weights + Vowel Harmony in TypeScript

Instead 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:

type Harmony = "front" | "back";
type Boundary = "vowel" | "liquid" | "nasal" | "stop" | "fricative";

interface Morpheme {
  text: string;
  gloss: string;
  harmony: Harmony;
  onset: Boundary;
  coda: Boundary;
  weight: number;
}

// Allowed coda -> onset transitions (0 = forbidden)
const TRANSITION_WEIGHT: Record<Boundary, Record<Boundary, number>> = {
  vowel:     { vowel: 0.1, liquid: 1.0, nasal: 1.0, stop: 0.9, fricative: 0.8 },
  liquid:    { vowel: 1.0, liquid: 0.15, nasal: 0.6, stop: 0.7, fricative: 0.5 },
  nasal:     { vowel: 1.0, liquid: 0.4, nasal: 0.1, stop: 0.8, fricative: 0.5 },
  stop:      { vowel: 1.0, liquid: 0.5, nasal: 0.2, stop: 0.0, fricative: 0.1 },
  fricative: { vowel: 1.0, liquid: 0.4, nasal: 0.3, stop: 0.2, fricative: 0.0 },
};

function pickWeighted<T>(items: Array<{ item: T; score: number }>, rng: () => number): T {
  const total = items.reduce((sum, x) => sum + x.score, 0);
  let r = rng() * total;
  for (const entry of items) {
    r -= entry.score;
    if (r <= 0) return entry.item;
  }
  return items[items.length - 1].item;
}

export function buildName(
  roots: Morpheme[],
  suffixes: Morpheme[],
  rng: () => number = Math.random
): { name: string; meaning: string } {
  const root = pickWeighted(roots.map((m) => ({ item: m, score: m.weight })), rng);

  const scoredSuffixes = suffixes
    .map((suf) => {
      const boundaryScore = TRANSITION_WEIGHT[root.coda][suf.onset];
      const harmonyBonus = root.harmony === suf.harmony ? 1.0 : 0.25;
      return { item: suf, score: suf.weight * boundaryScore * harmonyBonus };
    })
    .filter((x) => x.score > 0);

  const suffix = pickWeighted(scoredSuffixes, rng);
  const raw = `${root.text}${suffix.text}`.replace(/(.)\1\1+/g, "$1$1");
  return {
    name: raw.charAt(0).toUpperCase() + raw.slice(1),
    meaning: `${root.gloss} + ${suffix.gloss}`,
  };
}
Enter fullscreen mode Exit fullscreen mode

Three details do most of the heavy lifting here:

  • Hard zeros on stop -> stop and fricative -> fricative: Eliminates kt-, gd-, sz-, and fv- collisions at the join point.
  • Soft vowel-harmony multiplier (1.0 vs 0.25): Front vowels (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.
  • Triple-letter collapse (/(.)\1\1+/g): Catches edge cases where a coda letter duplicates an onset geminate (l + ll).

3. Phoneme Design: Moonlight/Nature vs. Solar/Astral Elven Families

When 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). Even within a single species, shifting liquid/nasal ratios and syllable counts produces immediately recognizable families:

Design Axis Moonlight / Woodland Elven Solar / Astral High-Born Elven
Core Onsets Soft stops & nasals (/m/, /n/, /t/, /ʃ/) Liquids & sibilants (/l/, /r/, /s/, /v/)
Dominant Vowels Balanced short/long (/a/, /i/, /u/, /o/) Front & diphthong-heavy (/eː/, /iː/, /aɪ/, ae)
Syllable Target 2–3 syllables given name + compound surname 3–4 syllables given name + patronymic or house affix
Semantic Roots Moon, owl, shadow, grove, whisper, tide Dawn, star, crown, spire, crystal, flame
Example Structure Syl- + -varis → Sylvaris, Lyr- + -eth → Lyreth Ael- + -arion → Aelarion, Cal- + -endil → Calendil

Traditional Elder Scrolls lore documented in the UESP Altmer naming documentation 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 exposes the semantic breakdown alongside each generated name.

4. Deduplication Beyond Exact String Checks

Checking 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.

A fast, zero-dependency deduplication filter combines three checks:

  1. Seeded PRNG (Mulberry32) so reproducible lists can be cached per campaign seed.
  2. Phonetic skeleton key: Strip vowels after the first character, collapse double consonants, and normalize y -> i, ph -> f, c -> k. Both Aelarion and Aelaryon hash to ALRN, blocking near-homophones in the same batch.
  3. Bounded Levenshtein window (distance >= 3): Against the last 20 accepted names, reject any candidate within edit distance 2 so a single page never clusters around one prefix.
function phoneticKey(name: string): string {
  const lower = name.toLowerCase().replace(/[^a-z]/g, "");
  if (!lower) return "";
  const head = lower[0];
  const tail = lower
    .slice(1)
    .replace(/ph/g, "f")
    .replace(/[cy]/g, (ch) => (ch === "c" ? "k" : "i"))
    .replace(/[aeiou]/g, "")
    .replace(/(.)\1+/g, "$1");
  return head + tail;
}
Enter fullscreen mode Exit fullscreen mode

5. Pre-Ship Sanity Checklist

Run a 1,000-sample smoke test before shipping and assert four metrics:

  • Max consecutive consonants ≤ 2 unless whitelisted for a guttural culture.
  • Unique phonetic keys ≥ 95% across a 50-name batch.
  • Length within 4–13 letters so names never truncate in RPG HUD plates.
  • Read-aloud pass: Read 15 random outputs at normal pace; any pause exposes a missing zero in your transition matrix.

Phonotactic weights take under 100 lines of TypeScript, run in microseconds on the client, and eliminate the gibberish that breaks immersion.

Top comments (0)