Simple Name-Generator

Post your FreeBASIC tips and tricks here. Please don’t post your code without including an explanation.
Haubitze
Posts: 37
Joined: May 20, 2016 8:42

Simple Name-Generator

Postby Haubitze » May 30, 2019 14:20

hey there,

i was looking for some good namegenerators but all have a list of forenames and so on or using sybils.
so i was thinking about that problem an came with my own solution to here.

for clearness i used a Martin Luther bible (in german) to generate a list of "frequencys" of following letters for each letter in the german
alphabet. excluded ä,ö,ü,ß all this are (ae,oe,ue,ss), then i translated it to two arrays, the first holds the total number of following letters
the other one holds the following "frequencys".

first i get a beggining letter and a following letter.
then i calculate a chance for the following letter. if the randomizer is bigger then that chance
it will get a new following letter, if not it will add the begining letter to the string and set the value of the beginning letter to the
value of the following letter and the folowing letter becoms a new value. and so forth.

while i searched all the good forums and google i was not possible for me to find a nice solution so here it comes.

Code: Select all

Function get_sysname(seed As uinteger) As String
   Dim n As String
   'this is the magic bible code (a german bibel translated by Martin Luther)
   Dim magic1(0 To 25) As UInteger={192820,56937,83962,157213,483371,27962,75240,140118,241061,11546,27544,91242,56951,178568,79338,18286,134,138139,168794,97790,136722,25685,56046,26,1231,30769}
   Dim magic2(0 To 25,0 To 25) As Integer = { _
   {1113,14697,13435,2855,15494,1532,7002,6037,949,317,855,15258,8425,26601,583,548,6,14254,27595,9836,23264,1459,21,6,-1,678}, _
   {4419,284,-1,93,32596,50,298,100,4204,62,24,2013,12,141,2350,-1,-1,5097,1453,2192,1309,2,55,-1,18,165}, _
   {17,-1,-1,-1,3,-1,-1,81017,7,-1,2913,-1,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,-1}, _
   {31313,92,2,322,84296,85,37,61,26185,37,14,459,49,290,2068,50,-1,1469,628,2143,7287,80,43,-1,-1,203}, _
   {954,13694,7768,7028,2011,2995,8699,17113,60018,43,1191,20446,17345,123996,278,1047,3,124477,41049,18142,10687,628,2938,14,-1,807}, _
   {2995,42,-1,23,8295,1232,389,183,1172,-1,52,1849,83,169,670,1,-1,3108,371,2258,4690,-1,36,-1,-1,344}, _
   {3119,74,-1,175,46942,137,186,37,2342,-1,770,2882,15,1174,5783,1,-1,3280,1392,4946,1210,1,29,-1,734,11}, _
   {23045,67,-1,97,36468,60,75,61,6949,79,318,4818,5566,10856,5191,14,-1,17148,1712,22732,2892,-1,1721,-1,20,229}, _
   {1148,2954,32812,5072,49287,912,12512,17346,2,25,135,8515,5607,57670,301,253,-1,11731,19763,14391,302,23,31,11,-1,258}, _
   {3566,-1,-1,-1,4132,-1,-1,-1,65,-1,-1,-1,-1,-1,1756,-1,-1,-1,-1,-1,2027,-1,-1,-1,-1,-1}, _
   {3543,14,3,1,7258,5,15,63,3169,3,113,1207,26,1310,7423,1,-1,1025,377,1156,806,1,10,-1,7,8}, _
   {10130,2309,2037,2254,22320,870,591,76,9976,154,2846,18446,374,828,2972,20,-1,38,5218,6773,2496,11,36,-1,26,441}, _
   {9881,80,-1,305,17572,14,172,405,12202,19,127,382,7013,112,3139,530,-1,117,866,1675,2269,-1,15,-1,29,27}, _
   {9129,721,68,70844,33226,1052,10197,415,15091,302,2240,388,222,12296,2133,122,2,612,7346,6939,2519,109,389,-1,14,2192}, _
   {614,2216,3565,1683,11519,710,1176,5708,15,116,86,11236,4698,10927,-1,2210,1,10705,4612,7414,2,31,34,-1,-1,60}, _
   {671,-1,-1,-1,1354,2456,-1,2530,387,-1,-1,249,-1,14,419,280,-1,8207,121,1378,220,-1,-1,-1,-1,-1}, _
   {-1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,133,-1,-1,-1,-1,-1}, _
   {16142,2783,2295,11698,27114,1828,3297,1627,10736,206,2211,2006,1453,11998,4938,134,59,10195,6914,9151,7645,117,1108,-1,7,2477}, _
   {11316,281,13566,119,34536,121,741,485,20798,58,351,188,138,33,16885,7254,-1,3610,21873,32571,3399,70,130,-1,271,-1}, _
   {9255,184,2,49,50432,138,385,3054,3762,23,24,1202,181,222,3086,-1,-1,4841,1830,11071,3992,19,1206,-1,91,2741}, _
   {316,1702,7467,1907,20103,9036,2456,783,78,57,223,1660,6873,61188,2,689,-1,5591,11786,4413,2,222,27,-1,-1,141}, _
   {1836,-1,-1,-1,6220,-1,-1,-1,3339,5,-1,12,-1,7,14259,-1,-1,-1,1,-1,-1,6,-1,-1,-1,-1}, _
   {12976,-1,-1,-1,17277,-1,-1,-1,17051,1,-1,-1,-1,-1,6496,-1,-1,-1,1,-1,2242,-1,2,-1,-1,-1}, _
   {10,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,6,9,-1,-1,-1,-1,-1,-1}, _
   {5,2,7,5,8,-1,4,-1,-1,-1,2,19,5,6,1,747,-1,385,20,2,-1,-1,-1,12,-1,1}, _
   {1025,18,-1,-1,7357,1,5,25,2504,40,6,94,22,2,1435,50,-1,48,19,987,15284,3,1829,-1,12,3} _
   }
   Randomize seed'set the seed
   Dim m0 As UInteger=Int(Rnd*26)'get a letter
   Dim m1 As UInteger=Int(Rnd*26)'get a folowing letter
   Dim l As UInteger=2+Int(Rnd*6)'set the lenght of the name
   For i As UInteger=0 To l'loop over name lenght
      Dim chance As Double=magic2(m0,m1)/magic1(m0)'set the chance that the folowing letter appiers
      While Rnd>chance'if chance is to low get a new folowing letter
         m1=Int(Rnd*26)
         chance=magic2(m0,m1)/magic1(m0)'and set the chance to the new value
      Wend
      n+=Chr(m0+97)'add first letter to the string
      m0=m1'set first letter to the folowing letter
   Next
   n[0]-=32'make the most first letter upper case
   'Print n
   Return n
End Function

i think the generated names are not so bad and i hope anyone will use it ;)

salute

PS: you can generate a "frequency" list of your own language when you use a bit programming and a big text in your language.
PPS: if you have suggestions to improve the function let me know ;)

Edit: oh for demo it will produce names like this list

Code: Select all

Ist
Jeierr
Funde
Fuerteng
Einde
Xabierz
Ueiesc
Rnndach
Herers
Zuh
Minduc
Ginicht
Spr
Erun
Ichr
Ieigomd
Dachtte
Mamaric
Omest
Serg
Tehrd
Utt
Letenn
Uesse
Qucha
Chra
badidea
Posts: 1575
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Simple Name-Generator

Postby badidea » May 30, 2019 15:35

Mr. or Ms. Spr?
dodicat
Posts: 5980
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Simple Name-Generator

Postby dodicat » May 30, 2019 17:15

Similar, not necessarily names, but sentences derived from a text file sample of an author.
https://www.freebasic.net/forum/viewtopic.php?f=3&t=16207&p=241591&hilit=%2Aflavour%2A#p241591
(The updated triplets post)
Haubitze
Posts: 37
Joined: May 20, 2016 8:42

Re: Simple Name-Generator

Postby Haubitze » May 30, 2019 17:53

yes dodicat, mine is also more gobblygook ;D
but yeah similar aproach.

edit @badidea yeahim a german an here is the name Herr Spr not so rare :floet:
dodicat
Posts: 5980
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Simple Name-Generator

Postby dodicat » May 30, 2019 19:21

A bit from Genesis:
And unto died. And lament of the plening, and the fall that
of the prese to his in know, les taked said, and unted hiddekel
the evil thost thou earth upon the lieth day, and of not enmity
yearth in slew his dwell whence of thirty ye eight his he garden
you had my put ourt. And evenfold it grow not easanceives the
seven there to came a son togethusael he died.

not this one
https://www.youtube.com/watch?v=DyDRXbP1MaY

RIP
Haubitze
Posts: 37
Joined: May 20, 2016 8:42

Re: Simple Name-Generator

Postby Haubitze » May 30, 2019 19:25

nice one :D
Haubitze
Posts: 37
Joined: May 20, 2016 8:42

Re: Simple Name-Generator

Postby Haubitze » May 30, 2019 21:40

btw: hiddekel(hezekiel,ezechiel) are my favorite "prophet" ;D

Return to “Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 1 guest