I spent today coding a name generation algorithm.
It combines commonly found syllables (and syllable pairs) in names to get a realistic output.
[code]syl = {“liz”,“beth”,“char”,“lie”,“rie”,“tri”,“von”,“do”,“wal”,“fra”,“mer”,“sha”,“ru”,“by”,“al”,“ex”,“ob”,“es”,“elda”,“cher”,“mo”,“mart”,“in”,“dy”,“can”,“an”,“kev”,“hin”,“du”,“fred”,“geof”,“rey”,“ney”,“aul”,“grim”,“grin”,“grif”,“on”,“pil”,“val”,“ray”,“ar”,“car”,“mel”,“dom”,“dor”,“nic”,“nik”,“las”,“o”,“ow”,“frey”,“un”,“roy”,“esh”,“flor”,“ence”,“encia”,“lor”,“ju”,“jen”,“jo”,“lia”,“rin”,“bal”,“rof”,“dof”,“ing”,“red”,“rus”,“bus”,“les”,“ful”,“nie”,“ska”,“fa”,“li”,“kra”,“kov”,“vin”,“sky”,“ski”,“don”,“cia”,“nick”,“rick”,“leo”,“thor”,“na”,}
function GenerateName(names)
local namest = {}
for n = 1,names do
local namet = {}
for s = 1,math.random(2,3) do
local syll
repeat
syll = syl[math.random(1,#syl)]
until syll ~= namet[s-1]
table.insert(namet,syll)
end
namet[1] = string.upper(string.sub(namet[1],1,1))…string.sub(namet[1],2)
table.insert(namest,table.concat(namet))
end
local namestt = {}
for j,v in pairs(namest) do
table.insert(namestt,v)
if j < #namest then
table.insert(namestt," ")
end
end
namest = namestt
namestt = nil
return table.concat(namest)
end
for i = 1,5 do
print(GenerateName(math.random(2,3)))
end[/code]
Feel free to use it however you like.
Example output:
Kovcan Rujolas Jona
Nady Auldofcar Lithor
Encerie Rukov Obdofpil
Grifelda Rickfredgrin
Lianickru Fredvinvon Dofrie