Generating random names using maths?

Wanna learn how to use probabilities and randomness to procedurally generate nice-sounding names? :)

Mina Pêcheux
CodeX
Published in
8 min readAug 11, 2021

--

In a recent series of posts, I talked about finite state machines (FSMs) and how they can model entity behaviour. But state machines can also be used to generate data.

Recently, I used state machines to create a little name generator called rangen-name. (Ultimately, it will be part of a suite of random generators and procedural generation tools: rangen - even though for now it's the only one ;) ) It's written in vanilla JavaScript and it's available either on NPM or as a Github repository.

It produces really nice names that I think are quite credible! For example, it generated those ones:

Barbara Ovie
Jefferson Kerlyn
Torr Farl
Missy Brea
Albatros Riddym
Eunice Harmanlew
Paddie Crid
Sollie Peltmar
Quint Wort
Dawson Haddye

The tool can produce either a firstname (that’s picked at random from a list of common firstnames), a lastname (that produced thanks to a Markov chain, a specific kind of FSM) or a combination of the two to give you a full name, like here.

Note: you can pass it either a “male” or “female” parameter to specify the gender of the name you want to generate! ;)

A screenshot of rangen-name's Github page

TL;DR: how to get and use the rangen-name package!

If you want to try it out without installing anything, you can use the CDN version of the package and use it directly in an HTML page:

Or else if you’re working with Node, just:

  • download the package using npm or yarn:
npm install @mpecheux/rangen-name
# or: yarn add @mpecheux/rangen-name
  • import it in your project using the ES5 or ES6…

--

--

Mina Pêcheux
CodeX
Writer for

I’m a freelance full-stack web & game developer. I’m passionate about topics like CGI, music, data science and more! Find me at: https://minapecheux.com :)