Katsuri's Random Word Maker

by Katsuri
A small program/library designed to create a random word based on common English (American) spelling patterns
ID:463298
 
I wrote this up in about a weekend and figured I would just throw it to the side. The library comes with a demo to show how it works. There are probably a few quirks in it and it spits out gibberish fairly often. Even then, it's a great program for several different genres. A new magical spell or some random name for a guild. Perhaps a new language? It's all up to you and your imagination!

It is, as any other library, also set up so you can just pull the procs from the code to use in your own game. In this way, you can just generate a random word for a verb or whatever. If it will be referred to, however, you need to make sure it's saved because the proc will always generate a random word! Actual words are possible as well, so be careful.

Credit is nice, but not entirely needed!

It is also probably over-commented and quite frankly I had it set up for the complete newbie. If this is just too much, then please let me know, same with any quirks I could try and fix as well. Thanks!
Firstly, there is a goto loop that is absolutely unnecessary. Secondly, one reason you get mostly gibberish is that you're working on a highly abstract level, far away from the actual phonetics involved. The easiest way to make non-gibberish words is by dealing with and understanding phonotactics, but that involves a relatively-detailed knowledge of phonology, and also requires an at least somewhat-reliable method of determining how a word is written based on the phonemes present in it; unfortunately, in English, these rules are complex and, quite often, entirely irregular.
about the phonotactics- yeah, I know they're quite advanced which is why I made a specific note about finicky programming and such. If I get too many comments, I might decide to delve into the topic and update the system, but I don't feel too much like typing out a massive, specific piece of coding just to tell the system that it should use "au" instead of "ou"

Now that goto loop... I thought it might be poked at but I honestly have done several loops like that. Perhaps make a second proc that adds another portion onto the word? If there are any other ways for a similar outcome, I haven't learned them, but I'm open for suggestions.
In response to Katsuri
Katsuri wrote:
Now that goto loop... I thought it might be poked at but I honestly have done several loops like that. Perhaps make a second proc that adds another portion onto the word? If there are any other ways for a similar outcome, I haven't learned them, but I'm open for suggestions.

IIRC, from what I saw all you really need is an else if statement.
It might help to make better words if you have lists similar to clist and vlist that are specifically for the start of a word. That way things like "ngue" and "zz" can still be parts of words, but won't be used to start a word. It would also be helpful to include examples of different sets of lists to show how you can change the lists to create different sounding words.

I didn't have a demo with the library, it was just Wordmaker.dm.

I cleaned it up a bit. Some of the changes are superficial, some aren't.

proc
// grab a sound from the vowels list
getv()
return pick(vlist)

// same here except with consonants
getc()
return pick(clist)

makeword(min = 1, max = 5)

// make sure max is greater than min
if(max < min)
max += min

var/word = ""

// 50% chance to start with a consonant
if(prob(50))
word += getc()

while(1)

// if we're at the limit return the word
if(lentext(word) >= max)
return word

// if we're over the required length there's a chance to return the word
if(lentext(word) >= min)
if(prob(50))
return word

// otherwise we add to the word
var/v = getv()
var/c = getc()

// add v and c to the word if they don't put us over the limit
if(lentext("[word][v][c]") <= max)
word = word + v + c

There are a lot of places where you do something like "[variable]" when you don't need to because the variable is already a string.

There's a chance for an infinite loop (which I didn't fix here). If the word you're building up is 7 letters long so far and the max is 8, any combination of v and c that you pick will put it over the max (which means they won't be added to the string, the loop will iterate again, and you'll never find a combination that works).
I see...
Thanks! I forgot about while, dear god what is wrong with me!?

Also, about the infinite loop, the only thing I can think to do with it is to make it count the amount left over to the max and find anything in either list that would match it. I could play off what you stated and set up an "endings" list for it to hunt through.

Another thing, I swore I set it up to include a demo, or I chose a file for it to include. I will try and see if I can redo that to get the demo up.

Edit- Alright, I have it updated (hope you didn't mind me adding your code and working on it). I even included a way for there to be beginning and ending specific sounds and spellings so that words work smoother. It still spits out one or two pieces of gibberish, but it's spelling out much smoother words. Thanks for the help guys :)
I think if you use Dream Maker's ability to package files as a .zip, it only includes files that are currently included in the project. If the demo files aren't included you have to specify them manually or just zip the files manually.

Also, about the infinite loop, the only thing I can think to do with it is to make it count the amount left over to the max and find anything in either list that would match it.

You'd have to make it able to end in a vowel then. Currently if you're one letter short of the max, any vowel and consonant combination will put you over the limit.
Yeah, I have been specifying DM manually to put the Demo files into the zip...I will look further into it even though I've even opened the zip recently to make sure the demo files are in there, which of course they are.

I think the thing I have set up right now should work. It has a separate list that will give it an ending. It doesn't ALWAYS give an ending from that list, but it's working pretty well now that I have it included. On another note. I went in and made sure that each list (except the beginning list) has at least one sound that only includes one letter. So it shouldn't even loop now. But let me know if it might