Blueprint name generator using Markov chains

UPDATE: I’ve updated this project after six years. The old post with the old files can be found further down in this post.

You can download the new version from GitHub here

So apparently this post I made six years ago is still what shows up when people google random name generator in blueprints. I couldn’t with good conscience let people use the clunky implementation I made back then so I spent an evening making a fresh version. It was a fun excercise to try to recreate something like this, and I hope some devs might find the result useful.

This is the sort of thing that makes more sense to do in C++ than blueprints, but it should still be fast enough for many potential implementations. The slow part is generating the markov data from the word lists, but it only needs to be done once, and actually generating names from these lists is very quick. I threw in a name list of the top 1000 male US names, which causes some dropped frames when you first generate the data, but creating names from the generated data is basically as fast as for the ones generated from the shorter name lists.

The update makes the code cleaner, much faster and uses much less memory. I’ve also set it up so you can easily add new word lists by importing a csv. A sample csv is included that is formatted appropriately. If you import a new one, import it as a data table using the FNameList struct and set that data table as the NameDataTable variable in the BP_NameGenerator blueprint.

Here is a quick clip of the new version in action:


OLD POST:

I’ve been toying around with random name generators for a while, and recently I read about Markov chains.

Markov chains is a way to take a list of names/words or anything really, find their patterns and create random elements based on these patterns. For names you would look at all names in a list and create a probability list based on how often a certain letter follows another letter/pair/triples of letters. You then pick a random letter pair and select the next letter based on the probability of this letter appearing after this pair in your list. Then you look at what are now the last two letters and repeat the process.

That’s a pretty simplified explanation, but markov chains are actually pretty simple. A benefit of using Markov chains for name generators is that you will generally generate names that sound similar to the lists they are based on. You can thus easily create custom name generators for French names, dwarven names, names of diseases etc.

A drawback to the method is that you need fairly large lists of names for it to work properly. I’ve got a list of 100 names, and that’s barely enough for it to work, and that’s when I look at two letters at a time. It’s recommended to use three letters at a time when generating probability lists and that would require even larger name lists. Blueprints are probably not the best fit for these sorts of things, as list generation is pretty slow even with just 100 names, but that being said I’ve thrown this together very quickly, so there’s much room for improvement. Also, the slow part of the method is generating the lists, and they only need to be set up once, after which names can be generated quickly from the lists.

Anyway, sometimes it works pretty well:
6f0429daa7c0048fe30409bf65228a648594c179.jpeg

Other times less so:

So like I said, much room for improvement (setting it up to import external name lists for one), but it’s a fun little example of how to do simple random generation with blueprints. I might do something similar using C++ in the future. But for now, enjoy!

NOTE: Below are the old files from 2015. For the new ones see the link at the top of the post:
LINK TO OLD FILES (The relevant bluepring graph is in the level blueprint. Left click to generate new names)

2 Likes

Hey, this is so awesome! You have no idea how much this has helped me :slight_smile: I put in about 200 Japanese male names and it worked absolutely beautifully. This really does allow for a huge amount of randomly generated names! Incredible, keep up the great work and thank you so much!

Really cool thing, thanks for sharing :slight_smile:
PS. vivivivivia is a beautiful name, what’s wrong with it? ;D

For the vivivivivivia type cases, you could step through the generated string 2 chars at a time and search for the same substring elsewhere in the name and then regenerate it if you find too many duplicates. Of course a larger dataset would probably be enough. This site is an amazing resource for that: http://www.fakenamegenerator.com/order.php (you can download name sets in bulk for free)

Really cool demo, thanks for sharing.

Strange. Even though I’m subscribed to this thread I never got any notifications of comments. I thought it had simply garnered no interest, but I’m happy to see it was of use to people after all :slight_smile:

Thanks! You can actually use markov chains for many things besides generating random names. If you use words instead of letters and sentences instead of words you can generate random poems, articles and many other things. A couple of fun examples are Garkov, which generates random Garfield comics based on multiple original comics and Jesus Markoving Christ, which generates random Jesus quotes :smiley:

I’m considering it as a name for my first daughter, but I’m afraid people would assume she has a stutter.

Yeah, that’s absolutely one way to prevent it. And that’s an extremely useful site. Thanks!

Thanks a lot for this.
There is a small issue though, the array getter is ending at nonexistent indexes, which throws warnings. I’ve fixed it with additional check. Here is the fix, in case someone else needs it:
https://blueprintue.com/blueprint/idhbivyz/

Thanks for the fix, Eskel :slight_smile: How did you find this thread after six years? Would be fun to take a new look at this code one day and see if I can make any improvements after all my years of added experience.

1 Like

Ok, I spent an evening making a new version of this generator. I did it from scratch, so the code is completely different Link to my GitHub with the files can be found at the top of the original post, which I’ve edited. Hope this will be useful to some of you!

@Eskel : If I were you I’d get the new files instead of using the old ones. New version is much more performant.

@Monokkel Just from google search, was looking for a name generator for my game. Thanks for the update, that’s awesome. :slight_smile: Gonna give it a try.