|
Post by Wayne Rayner on Aug 20, 2013 20:41:26 GMT -5
Hey guys,
I need the theory not code for random generation of names. My game is a semi sim/rpg on the world of racing. You dont get to do racing as 2D racing just is not how I want the game to work. But you create a player and start him off in go-karts at the age of 14 in the Junior Karting Championship. If you do well in this championship you can get a sponsor who will buy you a clubman kart which is the next level of the game. The game goes to NASCAR, F1 and even Indycar championships. However for the game these championships will be National Sprint Car Championship (NSCC), World Open Wheel Championship (WOWC) and American Open Wheel Championship (AOWC).
So basically the game will have a lot of different racing championships to be able to play in and will take a lot of effort in creating over 1500 driver names. So instead I want to randomly generate Drivers First and Last Names add age and stats like speed, cornering etc.
I can do age generation fairly easily as well as stats it's just with names where I'm having problems.
I mean it will be a crap game if each level you are against driver 1 to driver 20 for instance would rather generate like Mike Love, Michael Johnson for instance. So I have got a way that I could implement and it wont be as hard as creating a custom first and last name generation program but then it would get fairly boring once all first and last name possibilities are taken. Basically a list of first names and last names will work and then the game on a new game will use these randomly to generate enough drivers for each championship until the player turns 80. As players can create racing teams and manage them.
I know it is a huge game but it will be really really good and no racing sim or manager game is going to be like this.
|
|
|
Post by matthew on Aug 21, 2013 15:08:22 GMT -5
Well this could be done quite easily, all you need to do is create 2 different arrays. One containing the forenames and the other other containing the surnames, then you could randomly choose them.
randomize()
dim foreName$(4), surName$(4), i, j, k, a, b
' a list of forenmaes data Paul, Mark, David, John, Tom
' a list of surnames data Smith, Lawson, Whiskens, Needham, White
for i = 0 to 4 read foreName$(i) next
for j = 0 to 4 read surName$(j) next
for k = 0 to 4 a = rnd() % 5 print foreName$(a) ' print a forename print " " ' print a space b = rnd() % 5 printr surname$(b) ' print a surname next
|
|
|
Post by Wayne Rayner on Aug 29, 2013 10:24:31 GMT -5
Thanks Matthew, However I will be using C++ for this project for 2 reasons 1) is because my brother bought me a C++ book as well as a book on 2D game programming with SDL. 2) also because I have gotten a person helping me with the project and he is proficient in C++ and SDL and I have a graphics artist in 2D Glad that I managed to get these guys to help me out though
|
|
|
Post by shadow008 on Aug 29, 2013 14:42:17 GMT -5
|
|
|
Post by Supermonkey on Sept 26, 2013 6:17:56 GMT -5
Moved as it's not Basic4gl related.
You should be able to translate the above B4GL code pretty easily. If not I would recommend doing more reading before embarking on a game.
|
|
|
Post by dw817 on Aug 17, 2015 21:38:13 GMT -5
I wrote a random name generator many years ago as an experiment in creating a virtual world.
The principal is a simple one. First you have the vowels, A, E, I, O, U. (not sometimes y)
Then you have the consonants. B D F G H J K L M N P R S T V W Z
You can add letter Y to the consonants but you might get a weird name if you do. Leave out C because it can make both a K and S sound, likely messing up your name. Leave out Q as in English a U is always required after it.
Then it's a simple process.
You can have a name like CVCCVC where no letters are repeated, or even VCCVCV.
You could get "Takvoy" or "Ersuna"
If you want the code to do it, lemme know, it's simpler than it sounds.
Hope This Helps !
|
|
|
Post by Adam on Aug 21, 2015 12:08:10 GMT -5
I wrote a random name generator many years ago as an experiment in creating a virtual world. The principal is a simple one. First you have the vowels, A, E, I, O, U. (not sometimes y) Then you have the consonants. B D F G H J K L M N P R S T V W Z You can add letter Y to the consonants but you might get a weird name if you do. Leave out C because it can make both a K and S sound, likely messing up your name. Leave out Q as in English a U is always required after it. Then it's a simple process. You can have a name like CVCCVC where no letters are repeated, or even VCCVCV. You could get "Takvoy" or "Ersuna" If you want the code to do it, lemme know, it's simpler than it sounds. Hope This Helps ! You intrigued me with your post, so I wrote a python script with what you said in mind (two different ways in fact import time import random vowels = ['A','E','I','O','U'] consonants = ['B','C','D','F','G','H','J','K','L','M','N','P','R','S','T','V','W','Z']
random.seed(time.time())
def isValidLetter(word, letter): if (len(word)> 2): if (word[len(word)-1] == letter): if letter in ['U','Y','X']: return False if (word[len(word)-2] == letter): return False if (letter == 'E'): if (word[len(word)-1] == 'I'): if (word[len(word)-2] == 'C'): return False return True
def getValidLetter(name,type): letter = random.choice(type) while(not isValidLetter(name,letter)): letter = random.choice(type) return letter
def createName(length): consonantCount = 0; nameLength = 0; name = "" if (random.choice([True, False]) == True): name += str(random.choice(vowels)) else: name += str(random.choice(consonants)) consonantCount+=1 while(nameLength < length): if (random.randrange(100) < 15): name += getValidLetter(name,vowels) else: if (consonantCount < 3): consonantCount+=1 name += getValidLetter(name,consonants) else: name += getValidLetter(name,vowels) consonantCount = 0 nameLength+=1 return name
def createFullName(): consonantCount = 0; firstName = createName(random.randrange(2,12)) lastName = createName(random.randrange(2,12)) return firstName + " " + lastName
def createSimpleName(): name = "" return getValidLetter(name,consonants) + getValidLetter(name,vowels) + getValidLetter(name, consonants)+getValidLetter(name,vowels) + getValidLetter(name, vowels)
print(createFullName()) print(createSimpleName())
and got results like UEUPCTAPH RPDUZPMAA JIZII SORVUOV EMKN VIZUI OJPNIRCON BCVUSVGAS VEBAI UPS CNL WOKIE EZNHAODIWCO EVVLIWOJD HUCAA DENSUEIWNSO UAMVP MEKOE WERA ABJMOD LIZUU ORNHAUEKCP AWBSE JAFEO HVDIEVKGI EMT ROWEI USAMAD IDZCAJKDOBTL HAZAA I was amused but not totally satisfied, so I did some googling which led me to www.sltinfo.com/syllables-and-clusters/ that explained possible consonant clusters (in the english language) and added that into the mix and came up with import random import time # consonant clusters cluster2 = ["sm", "sn", "st", "sk", "sp", "sf", "thw", "thr", "dw", "dr", "tw", "tr", "kw", "kr", "kl", "pr", "pl", "fr", "fl", "br", "bl", "gr", "gl", "shr"] cluster3 = ["spl", "spr", "str", "sfr", "skr", "skw"]
vowels = ['a','e','i','o','u'] consonants = ['b','c','d','f','g','h','j','k','l','m','n','p','r','s','t','v','w','z']
def getRandomCluster(): return random.choice([random.choice(consonants),random.choice(cluster2),random.choice(cluster3)])
def createSyllable(): rand = random.randrange(100) syllable = "" if (rand < 25): syllable += getRandomCluster() + random.choice(vowels) elif (rand < 50): syllable += random.choice(vowels) + getRandomCluster() elif (rand < 75): syllable += getRandomCluster()+ random.choice(vowels) + getRandomCluster() else: syllable += random.choice(vowels) return syllable
def createName(syllableCount): name = "" for i in range(0,syllableCount): name += createSyllable() return name
random.seed(time.time()) print(createName(random.randrange(1,4)))
with results like guprcespl struespre smuskr ispl spaeb statrskrudu ruiac ostruhnufr uozsplutr snibruhasm skrajibo ikw oprurskwo a vosfrbor usfr sfrotwoshro spruskracspre a flinukl it was a fun little experiment, but if you're looking for a generator that always creates a pronounceable name it seems like it would take a bit more complexity.
|
|
|
Post by dw817 on Aug 28, 2015 17:01:44 GMT -5
Hi Adam. Nope, you missed the structure I wrote. If you follow JUST "CVCCVC" and "VCCVCV" there's little chance of you creating a word that is unpronounceable.
If you want to absolutely always have a pronounceable word, use "CVCVC" or "VCVCV"
Just make sure to not use the letters, "C" "Q" "X"
It's also better if you create a word that does not repeat any letters. That is in that single word you produce, there are no repeated consonants nor vowels.
Hope This Helps !
|
|
|
Post by ayelis on May 20, 2016 19:01:15 GMT -5
It's also fun to work with phoneme pairs, if your concern is to make pronounceable words. It might actually help to use symbols from the International Phonetic Alphabet.
Consider which consonants are Plosive versus Fricative, and which are Voiced vs Voiceless, and match them in specific ways. Also, note that pairs like "Th" and "Sh" should be treated as a single phoneme (ð and ʃ), leaving you with the consonants: f/v, θ/ð, s/z, ʃ/ʒ, ʧ/j vs t/d, p/b, k/g, and the outliers; L, M, N, R, and H... Also note that there are a few common vowel dipthongs, and besides those, about 9 odd ways to pronounce the "five vowels" above, and you can even add Y and W to that list, as I do not believe to be consonants by any measure. Here's a collection of IPA symbols to represent all of the distinct vowels; äæøœɐɑɒɔɘəɛɜɞɤɨɪɯɵɶʉʊʌʏaeiouy.
I agree with what DW said above about C, Q, and X. Stick with ʧ, ku, and ks.
|
|