simple example of random name generator

Freeform discussion about anything related to modding Transcendence.
Post Reply
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

I coded a rudimentary name generator as a global function.

syntax:
(intNameGenerator number [string])

arguments:
number: number of names generated
string: can be Nil, "elfic" "russian" or "japanese"

Returns:
True when everything goes alright. :D


The string parameter changes the character sets to mimic the languages, if nothing is used, a default character set is applied.

How it works:
a very rudimentary coded sets of "if"s start the word, then a loop elongates the word, and depending on the characterset, sometimes a special diphthong is attached to close the word in order to increase similarity to the selected language. The generated names are printed in the console and in the debug.log

Here on xelerus for the download:
http://xelerus.de/index.php?s=mod&id=259


If a random mission generator is coded, I'm sure that a random name generator can be useful. :)
Also can be useful to add random names to spaceObjects.

Any ideas ?

[EDIT] Btw, some examples of what it can generate:
Normal

dija
ilotexegukuxanudufugu
ishiara
ocyraveqi
tyuru
odeomiqa
roovu
ehuayju
eqari
---------------

Elfic

athiunerh
blhodend
daurabarh
jyvibh
emhlhemadh
rapelith
napeneng
endiving
pupiwh
abypamelh
--------------

Russian

kjlu
etlhjodv
ugjzimunyje
mjamosoxigok
urjosarj
kjamut
afjasv
usijake
okredvm
okroze
--------

Japanese

woupo
bika
ossyoho
onnongukiriruzu
huwi
jonra
eccoukoou
nanhedari
gowoshi
wija
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

Actually the only difference in the various charactersets, are the limitations in consonants and vowels used and the use of particular diphthongs.

They have nothing in common to those languages, they just use the same sounds.
(actually from the japanese mode i got a couple of real japanese words, like maki, boku or sengetsu)

I don't know russian at all, and i don't know Sindarin or Telerin too, i just used a couple of resources on internet to get the phonemes for that languages, that's why i called them like that.

you can call the charactersets as normal, soft, harsh, and morpheme mode if you prefer. :)

Thanks for you comment Kaama. :D
User avatar
Prophet
Militia Captain
Militia Captain
Posts: 826
Joined: Tue Nov 18, 2008 6:09 pm

I like it.
There's tons of uses for it as well. The table of names is a pain to make and code. My only suggestion would be to shorten the 'max' output to between 8-10 characters, or (this might be more difficult) if it returns a string >8 select the first syllabel as a nickname.
Coming soon: The Syrtian War adventure mod!
A Turret defense genre mod exploring the worst era in Earth's history.
Can you defend the Earth from the Syrtian invaders?
Stay tuned for updates!
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

I was already asked to shorten the words on IRC.
So to address that I'm going to rewrite completely the function. (that is going to take some time)
The general idea is that the words should be simpler/humanlike and not a random collage of consonants and vowels.
I'm going to scrap the charactersets idea and approach a phoneme-like method, then the words will be simply driven by the arrays of phonemes. (i hope)
User avatar
Psycholis
Militia Commander
Militia Commander
Posts: 298
Joined: Sun Mar 05, 2006 8:23 pm
Location: Missouri

ilotexegukuxanudufugu

this is going to be my first born's name.
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

ok, I coded a name generator V2.
It's still simple enough to be customized as anyone wants.

Words are constructed from a list like ("h" "s" "s" "h")
where "h" and "s" are syllables with hard or soft sounds.
There a helper function that create list of lists for making the random length words.

The syllables are built from appropriate lists of consonants and vowels, depending on the language you want to imitate or to the "hardness" of the syllables.

the list for constructing the word can be customized also to use special morphemes or diphthongs.
For example:
("o" "h" "s" "e")
opening morpheme
hard syllable
soft syllable
ending morpheme


What else should I implement ?
george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

One thing you might consider (for V3) is to use a Markov chain to generate text.

Imagine that you had a structure like this:

Code: Select all

(setq markovNameTable
   '(
      ("al" 30   ("an" 25) ("be" 25) ("fr" 25) ("_" 25))
      ("an" 30   ("ne" 50) ("_" 50))
      ("be" 20   ("rt" 50) ("th" 50))
      ("ed" 10   ("_" 100))
      ("fr" 10   ("ed" 100))
      ("ne" 0    ("_" 100))
      ("rt" 0    ("_" 100))
      ("th" 0    ("_" 100))
      )
   )
Each element in markovNameTable represents a syllable and the probability that a given syllable will follow. In this table, there are only 8 syllables: "al", "an", "be", "ed", "fr", "ne", "rt", and "th".

The number after the syllable indicates the probability that the syllable will appear first in a name (e.g., the probability for "al" is 30%).

The sublists after that number indicate the probability that the given syllable will be followed by another specified syllable.

To generate a name, we use this algorithm:

1. Roll a random number from 1 to 100 and find the corresponding initial syllable. [E.g., we roll 15, so our first syllable is "al"]

2. This syllable is now our "current" syllable.

3. Lookup the current syllable in the table.

4. Roll a random number from 1 to 100 and lookup the syllable that will follow the current syllable. [E.g., our current syllable is "al" and we roll a 55. That means that the next syllable is "fr".]

5. If the resulting syllable is "_" then we're done. Otherwise, we append the syllable to the name. [E.g., Our name is now "alfr"]

6. The resulting syllable now becomes the current syllable. Go to step 3. [E.g., we lookup "fr" in the table and roll; the only possibility is the syllable "ed", so we keep on appending: "alfred" and continue.]

Here are some possible names generated by the above algorithm:

alan
beth
ed
albeth
alanne

Obviously these names get more interesting as the table gets larger.

Most importantly, it is possible to generate the table above by starting with a list of names and generating the probabilities that any syllable will follow another.

For example, imagine that I write an algorithm that takes a list of names. The algorithm decomposes each name into syllables and then calculates the probability that any given syllable will be followed by another. It then generates a table in the format above.

Once you have such an algorithm, you can feed it a list of names and get back random names that "sound like" the list of names that you gave it.
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

wow, that's professional! :shock:

We already have an algorithm that disassemble a string into a list for handling each letter and building the syllables.

Now I just have to code a script that build the Markov chain table with the probabilities and find a list of first names in various languages.
Post Reply