Generating Names

Date:

Since i first started developing things, i was fascinated with random name generators, but never had any real application for it. Until i developed my Pen & Paper Village Generator.

The easy way

The easiest way is to work with two lists of predetermined names. One for first and the other for last names.

IDfirstlast
1ThorinWildaxe
2BalinWhitebeard
3DwalinUnderhill
4OinOakenshield
5GloinStonefall
6DoriStoneskin
7OriGrimface
8NoriStronghand
9Ori
Two lists of dwarfen first and last names.

Now you generate a random number between 1 and how many entries the list „first“ has, and pick the corresponding name. Then you do the same with the second list, and combine these two names. The code would look something like this:

function randnumber(min, max) {
	return Math.floor(Math.random() * (max - min + 1)) + min;
}
let dwarfname = data["first"][randnumber(1,Object.keys(data["first"]).length)] +
data["last"][randnumber(1,Object.keys(data["last"]).length)];

Now you have a generator for dwarfen names. This is how the Fantasy Name Generator by Emily works. With the list above you get 72 unique names. But 72 is not that many names. You will see a lot of reiterating names even if you extend the list.

Generating one letter at the time

This solution gives you random names, without providing a template. But they are less specific on a race or gender.

const vocals = ["a", "e", "i", "o", "u"]; //defines the vocals.
const consonants = ["w", "r", "t", "z", "p", "s", "d", "f", "g", "h", "j", "k", "l", "c", "v", "b", "n", "m"]; //defines the consonants except Q,X,Y,
function GenerateRandomName(){
	let lenght = randnumber(3,8); //defines the length of the name
	let name = "";
	for ( let i = 1; i <= lenght; i++){
		let lastchar = name.charAt(name.length - 1) //outputs the last charakter in the name
		if (consonants.includes(lastchar)) { //checks if the last letter was a consonant
			name = name + vocals[randnumber(0,vocals.length -1)]; //pushes a vocal into the name
		}else{
			name = name + consonants[randnumber(0,consonants.length -1)]; //pushes a consonant into the name
		}
	}
	return name.charAt(0).toUpperCase() + name.slice(1); //makes the first letter uppercase
}

After it has decided how long the name should be, the program will pick either a random vocal or a random consonant. Before picking the next letter it checks if the last letter was a consonant. If so the next letter must be a vocal. After a vocal must follow a consonant. This is to prevent non pronounceable letter strings like „kzpg“ or „iiie“. Switching between vocals and consonants makes the Names more pronounceable. For this reason i haven’t included the letters Q, X and Y in the consonant array. This will output funny names like: „Desali“ or „Nejinow“, perfect if you need a stupid name for an NPC.

Combining the two methods

If you combine these two methods you get a solid name generator. For example the first name is generated by a list, but the last name is generated letter by letter. This will give you a name that sounds dwarfen, but if you need several names for a town with multiple dwarfs you don’t end up with NPCs with the same name. This improves if you choos at random if the first or the last name is generated letter by letter.