Creating names

Random name generation methods

Creating names: Random name generation methods

Introduction

No self-respecting roguelike game can live without random generators. While maps are usually random even in games with a hard coded plot, names are not always random, even if the characters bearing them are randomly generated (for instance, shopkeepers and ancient dragons in Ancient Domains of Mystery are generated randomly, but their names are picked from a hard coded list of names).

What drives many people away from random name generators is the difficulty their creation presents. Such generators usually output little more than rubbish, occasionally finding a name that's at least pronounceable.

The approach that has always called my attention was the syllable-based name generation. Instead of randomly picking letters or phonemes, such a generator will use syllables as an operation basis, effectively raising the chance of creating pronounceable names while still seeming random. In fact, the syllables provided to the generator can reflect a certain language or other desired feature of the names that are to be generated.

To see what glueing syllables together looks like, check this site.

Syllable division & generation pattern

The initial approach would be to simply define a single array or list of syllables and to happily start randomly glueing them together. This does not work out. It generates nonsensic babbling that, in many cases, isn't pronounceable at all. What has been successfully done in many a generator is the division of syllables into different groups and joining them according to a pattern.

A division that generally works well for character names is:

  • starting syllables,
  • middle syllables,
  • ending syllables.

This way, the possibilities of outputting a promounceable name are much higher, and the names can be easily themed by simply having a look at a list of names, say, in a given language and copying the desired starting, middle and ending syllables.

Example:

Let's take the Middle Earth's dwarves as an example. Here's a list of some of their names: Azaghal, Balin, Bifur, Bofur, Bombur, Borin, Dain, Dori, Durin, Dwalin, Farin, Fili, Fundin, Gamil, Gimli, Gloin, Groin, Ibun, Kili, Loni, Nain, Narvi, Nori, Telchar, Thorin, Thrain. The syllables would be divided like this:

syllablesStart = "A, Ba, Bi, Bo, Bom, Da, Do, Du, Dwa, Fa, Fi, Fre, Fun, Ga, Gim, Glo, Gro, Ib, Ki, Lo, Na, O, Tel, Tho, Thra"
syllablesMiddle = "za"
syllablesEnd = "bur, char, fur, ghal, in, li, lin, mil, ni, ri, rin, un, vi"

The syllable joining pattern will be, obviousy, Start+Middle+End, no spaces in between. The fact that there's only one middle syllable makes it a bit repetitive to see it in every generated name, so I've taken the liberty of making it have only 10% chance of appearing. The output of such a generator might be:

Baghal, Gloun, Dwaun, Groun, Bighal, Thoni, Fifur, Fari, Bazaghal, Dwabur

As you can see, they're all legible and might easily be considered valid dwarven names in Tolkien's Middle Earth. I have added more syllable sets to my name generator, with a different feel.

Norse:

Skjaldkull, Hedinastr, Hradveinr, Hoeggundr, Hviteifr, Gisulf, Fainn, Roegnleikr, Igulkundr, Spjallnarr

Based on names by David Eddings and Tolkien:

Turenarihor, Miromithel, Tarrakhad, Cuthigrim, Kuchak, Branafang, Megakor, Earydur, Urthoduruihor, Hettarath

Demonic names:

Pontastor, Orobotryuel, Rangoswath, Beelzeb'aephoddon, Tsabosias, Caimov-eflas, Mastoztuk, Naamubadhaka, Rahathe, Djurgophoswath

Word-based generation

OK, so we have this cool method. It's valid not only for character names, in fact, pretty much anything can be created with it. However, there are some cases when this won't work. For instance, charcter names might also have nicknames or surnames or whatever attached to them (Durin the Deathless, Dain II Ironfoot, Thorin II Oakenshield, Thorin III Stonehelm...). Another example might be towns: how does one randomly attach words like "Great", "New", "South" and such to a random name? Well, this can be achieved with a word-based approach.

Let's focus on the town name generation. The root name is easy to achieve with the standard syllable-based approach. Have a look at the UK in Google Maps and see how British towns are named. They are, in their majority, a conjunction of two words, plus an occasional addition. Let's enumerate a few cases:

syllablesStart = "Basil, Brain, Brent, Glou, Lon, Maiden, Queen, Stort"
syllablesEnd = "cester, don, end, ford, hampton, head, shire, try, wood"
additionalWords = "High, Great, South, Spa, Market, Port"

OK, so the words can be placed before as well as after the generated town name root? They need to be separated into different syllable sets and the generator needs to be informed of a possibility of adding either or both additional words, separated from the root name with spaces.

Here's some example output from the name generator I wrote:

Guildburg, Redhall, Pittsshire, Ellesmont, Bluemere, Greendorf, Old Firedale Heath, Copperthorpe Woods, South Goldhurst, Marshmoor

Using phonemes

Even though I indicated in the introduction that a letter-based or phoneme-based word generation usually bears miserable results, phonemes do have a use. Imagine you have a set of starting syllables that all end with a consonant, and both middle and ending syllables start with consonants as well. Some consonant-consonant pairs might be perfectly pronounceable, but there might as well be some that aren't: ZC, FG, JS, etc. What's more, some syllables might actually start or end with two consonants, resulting in a good chance of havin up to four consonants together, which is unacceptable unless you're making Czech names. In this case, specifying a list of vowels might be a good idea. Something like this might work:

vowels = "a, ae, e, ee, i, o, oo, u"

Same is true for consonants, of course.

Hard coded vs. scripted generators

A hard coded generator has one obvious advantage: it's fast. On the other hand, is speed really essential for a piece of code that will be called once every 10 minutes or less? It's also quite difficult to make a hard coded generator use a variety of name gneration templates (hey, not all names are generated like the examples above!), as each one needs to be hard coded as well. That's a lot of work to write it and introducing changes can be a pain too.

A scriptable generator will probably be a bit slower, as it'll need to parse an external file to extract all the data from it, along with the name generation templates. On the other hand, it'll have one piece of code for all the possible templates, so only this particular piece of code needs to be maintained. The actual meat for the program is in a text file, so introducing any changes (additional syllables, more unique generation templates, etc.) can be done immediately, without the need to recompile the generator.