Welcome, Guest. Please login or register.

Login with username, password and session length

Advanced search

1411951 Posts in 69435 Topics- by 58482 Members - Latest Member: Maiu

June 12, 2024, 04:14:32 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Procedural generator for names for anything
Pages: [1]
Author Topic: Procedural generator for names for anything  (Read 2094 times)
Level 0

View Profile WWW
« on: January 20, 2022, 09:04:05 AM »

I made a procedural generator to generate names for countries and cities in my turn-based strategy.

Here is the sample of its work

I think the community will benefit from making it public, as it can generate the names for anything: continents, people, mountains, dogs, using any alphabet. You just need to provide it a proper learning sample. And it does not use any of these fancy "neural networks". It works on good old Markov chains.

What is a Markov Chain

Did you notice that certain letters pairs can be found in the words quite often, while the others are almost non-presented? Obvious example: multiple worlds have letter pair "th" in them, but can you think of a world with a "tq" combination inside? Also different letters combinations tend to appear more often in various parts of the word.

So, we can define the exact probabilities for each letter following each other letter by processing a text large enough. Then we will be able to recreate a realistically looking text by starting from a random symbol and then selecting the next symbol using the weighted random function.

In reality for the better sounding of the procedurally generated names I used slightly more complex approach. My generator uses the probability for a symbol to appear after a combination of two previous symbols instead of just one.

Dependency on the learning samples

So, why do I say that this generator can generate names for anything? It's because it can define rules from any learning sample you provide it. There are 4 learning samples presets: Japanese provinces, European countries, USA cities and Russian names. The last one uses the Cyrillic alphabet, demonstrating that the generator can work with any set of symbols.

Once you select a preset (or fill in your own learning sample, one word in a line) press Generate button.

Here are some examples of its work

Japan provinces: Hyōtori, Kansaka, Nagate, Ibara, Yama, Chū, Tokka, Shigate

European countries: Belanden, Faria, Bavarussia, Engritaina, Ostaijand, Holdorttales, Vat Brand, Molstia, Yugaly

US cities: Fort Warra, Shree's Mempa, New Bersido, Las Chia, Wichmon, Madal Cuce, Daver, Northe, Worroleiminn, Salley, Wachmon

Russian names: Злав, Елия, Яростина, Надислана, Василав, Егорь, Крис, Лиания, Софьяна, Ясмира, Святон

Open the generator and play with it

How to integrate the generator into your game

Add the MarkovGenerator class to your project. Instantiate it and provide it the learning sample:

var gen = new MarkovGenerator()
Here learningSamplesAr is an array of strings.

And then you'll be able to generate new names by calling

var name4NewCharacter = gen.generate()
The class is written in Javascript and can be easily rewritten into other programming languages

Project on GitHub

Additional possibilities

If you provide a long text as a learning sample, you'll also receive a funny text as a result. This is what I've got when I provided the current post as the generator's learning sample:

Depealy gene candor starning slit a cand ther cany sountritin rearitaijan is wortion words Mem, Las samples itionsibing symbol to prov cou prov comessing symbolso generewChaingSample sames, The ener a Mole) prom an ding a le wript proce le world Ruside? Als the geneura, Sames bet of samade? It of ing fintor prearniting the in rearaties ong

You see - the text looks like English, it has the same letters spreading like in English text, but often it's so fun to read :D


I made a procedural generator for names for anything. You can play with it or find its code on Github to use in your game. If you like what I've made, you can wishlist my Conquicktory strategy game on Steam or play the current version on mobile stores.

CardWars - my turn-based strategy
Level 0

Long Jaunt

View Profile WWW
« Reply #1 on: January 25, 2022, 06:43:58 AM »

Good job!
I studied Markov chains at university, but I had already forgotten they existed.
"Владимирон" - That's a great name Smiley

Level 2

View Profile WWW
« Reply #2 on: January 25, 2022, 01:56:39 PM »

I've had lots of fun with Markov chains. And the algorithm is by no means restricted to letters.
- You can create procedural music by passing interesting melodies/harmonies for it. Note pitches and durations will be sufficient, so MIDI data works well.
- Stories (rather weird ones) can be created by passing words instead of letters (https://botnik.org/content/harry-potter.html).

Avaruustaistelupeli (ATP) - a space combat game
- Free download from itch.io or IndieDB
- Dev diary here
Pages: [1]
Jump to:  

Theme orange-lt created by panic