How I made a Name Generator

I thought this may prove helpful to some of you, so here it is. It is made in GD4, but since it is just Javascript code it can be used in GD5 as well…

First here is the code:

[code]var myVarName = runtimeScene.getVariables().get(“NameVar”);
var myVarCity = runtimeScene.getVariables().get(“CityVar”);
var name1 = [“Aba”,“Abde”,“Abre”,“Aby”,“Aca”,“Acle”,“Acri”,“Acro”,“Adme”,“Adra”,“Aea”,“Aegi”,“Aei”,“Aeo”,“Aese”,“Aeto”,“Aga”,“Age”,“Agi”,“Agri”,“Aia”,“Aka”,“Akti”,“Ala”,“Alco”,“Ale”,“Alka”,“Alki”,“Alo”,“Ama”,“Ame”,“Ami”,“Ana”,“Ane”,“Anta”,“Anti”,“Ape”,“Aphi”,“Apo”,“Arca”,“Arci”,“Arga”,“Ari”,“Arra”,“Arte”,“Asca”,“Asta”,“Asty”,“Atro”,“Atta”,“Aute”,“Bace”,“Bae”,“Bali”,“Bio”,“Boe”,“Bria”,“Care”,“Cea”,“Cele”,“Chae”,“Choe”,“Cine”,“Clea”,“Cleo”,“Cnoe”,“Coe”,“Cory”,“Croe”,“Ctea”,“Cyre”,“Dae”,“Dami”,“Damo”,“Dana”,“Davo”,“Dei”,“Dema”,“Demo”,“Deo”,“Dexi”,“Dia”,“Dio”,“Dore”,“Dori”,“Doro”,“Drya”,“Eche”,“Eio”,“Ela”,“Elpe”,“Empe”,“Endy”,“Enge”,“Epa”,“Epe”,“Ephi”,“Era”,“Ere”,“Ergi”,“Erxa”,“Euca”,“Eudo”,“Eue”,“Euge”,“Euma”,“Eune”,“Eury”,“Eva”,“Eve”,“Fae”,“Gale”,“Gany”,“Gaua”,“Glau”,“Gyra”,“Hae”,“Hagi”,“Hali”,“Hege”,“Heli”,“Hera”,“Hya”,“Hype”,“Iby”,“Ica”,“Ido”,“Illy”,“Ina”,“Iphi”,“Iro”,“Isa”,“Isma”,“Iso”,“Ithe”,“Kae”,“Kale”,“Kame”,“Kapa”,“Kari”,“Karo”,“Kau”,“Keo”,“Kera”,“Kleo”,“Labo”,“Lae”,“Lama”,“Lamu”,“Lao”,“Laso”,“Lea”,“Lei”,“Leo”,“Linu”,“Luko”,“Lyca”,“Lyco”,“Lysa”,“Lysi”,“Maca”,“Mae”,“Maia”,“Maka”,“Male”,“Mega”,“Megi”,“Mela”,“Mele”,“Midy”,“Mise”,“Mono”,“Nea”,“Nele”,“Neri”,“Nica”,“Nico”,“Nire”,“Nomi”,“Oche”,“Ocho”,“Oea”,“Oene”,“Oeno”,“Oile”,“Ona”,“One”,“Ophe”,“Ori”,“Orsi”,“Ory”,“Pae”,“Pala”,“Pana”,“Pani”,“Para”,“Pata”,“Pele”,“Peli”,“Peri”,“Phae”,“Poe”,“Poly”,“Saby”,“Saty”,“Sele”,“Sila”,“Simo”,“Sisy”,“Sya”,“Sylo”,“Syne”,“Tala”,“Teba”,“Tele”,“Tene”,“Theo”,“Tima”,“Tiry”,“Trio”,“Xena”,“Xeno”];
var name2m = [“ndros”,“bios”,“bulos”,“chus”,“cles”,“cydes”,“damos”,“dides”,“don”,“doros”,“dotus”,“gnis”,“goras”,“kles”,“kos”,“laus”,“leon”,“llias”,“llos”,“llus”,“machos”,“machus”,“menes”,“menos”,“mos”,“ndius”,“nes”,“neus”,“nidas”,“nides”,“nos”,“nthius”,“patros”,“phanes”,“phimus”,“phnus”,“phon”,“phoros”,“phorus”,“phus”,“pides”,“pompos”,“pompus”,“pon”,“ppos”,“rax”,“reas”,“rides”,“ros”,“sias”,“sides”,“sius”,“stius”,“stor”,“stos”,“stus”,“talos”,“thenes”,“theus”,“tios”];
var city = [“Argos”,“Assos”,“Carystus”,“Chalcis”,“Chios”,“Corfu”,“Corinth”,“Eretria”,“Erythrae”,“Karpathos”,“Kasos”,“Kos”,“Leros”,“Lindos”,“Marathon”,“Megara”,“Miletus”,“Mytilene”,“Naxos”,“Oenoe”,“Paros”,“Patmos”,“Patras”,“Phocis”,“Rhodes”,“Salamis”,“Skiathos”,“Sparta”,“Thasos”,“Thebes”];

var randName1 = name1[Math.floor(Math.random() * name1.length)];
var randName2m = name2m[Math.floor(Math.random() * name2m.length)];
var randCity = city[Math.floor(Math.random() * city.length)];
var randM = randName1 + randName2m
var randC = "of " + randCity
myVarName.setString(randM);
myVarCity.setString(randC);[/code]

This code calls two scene variables from my current scene “NameVar” and “CityVar” and assign them to the “myVarName” and “myVarCity” respectively.

Then I create 3 arrays in js “name1”, “name2m” and “city”. In “name1” I have the first part of the name and it is the largest of the 3 (about 200 different choices). In “name2m” I have the second part of the name (about 35) and in the “city” I have about 15 different ancient Greek Cities.

Then I have “randName1” to select a random value from the “name1” array, the “randName2m” to select a random value from the “name2m” array and the “randCity” to select from the “city” array.

Finally I set variables “randM” to combine the two parts of the name and “randC” to combine the word “of " and the random city and I assign them to the “myVarName” and “myVarCity” which will assign them to my scene variables"NameVar” and “CityVar”.

For the names to make some kind of sense and be somehow correct, I had the first part of the name always end in a vowel letter and the second part of the name always start with a consonant letter. For the male names, if you count the cities it gives 200 * 35 * 15 = 105000 different results.

I hope it makes some sense and you find it useful and if you me to make anything more clear just let me know…

You can find the current implementation of my name generator here. It gives 8 different characters and if you press Space it generates 8 more.

meviportal.itch.io/mythical-her … 0fkJYgeFgk

1 Like

I made something similar when I created my random NPC generator:

https://randomnamegenerators.io/generators/random-npc-name-generator

Hello! A little bit late but we have a similar algorithm on our name combiner. Anyone can check the JS source code files. Regards!! :heart_on_fire: