Saturday, 5 July 2014


Yesterday I started programming a [sorta kinda] working Random Name Generator in C. Unfortunately I haven't found a way to make the code compile and run through my blog [I doubt it's even possible] so this blog post will just elaborate on the process of creating the horrible awfulness that I named "namegen.c" [if you're not at all into programming I recommend you stop reading now before your brains im- and/or explode - I will not be held responsible for anything that happens to your brain even if you are into programming].

DISCLAIMER: I suck at programming harder than your mom did last night.

So I started programming with the framework inside the main() function, obviously. I created some obvious global variables because I cannot program and then I started working on the "insertLetterV2" function, the most important part of the name generator. It's a second version because the first one only had "half-baked" rules that barely made it any more readable. And that exactly is the main problem of a name generator: a name must be created that is both random and still readable at the same time. I came up with an ingenious idea [if I may say so] myself - you can read about this after the break!

I noticed that names that were generated completely randomly had on average as many Qs as Es, which isn't all that representative of usual names. Obviously a Q should only occur with a minimal chance whereas the E should occur quite more often. I came up with an idea of creating an array occurrence[] with approximately 1,000 values. The idea was to turn the occurrence frequency percentage of letters in the English language into occurrence amounts in the occurrence[] array. In this manner, the letter 'a' is found by indexing the array from occurrence[0] to something like occurrence[80], with 'b' starting at occurrence[81] for example. You get the idea [the code for this cannot be optimal but I don't give a shit, it works so it's something]!

With this in mind, I only added some basic rules like "no more than two consonants or vowels can appear consecutively", "after a 'q' add a 'u'" and "don't make a double 'v' or 'h' or 'x' etc". There are still too many erroneous combinations of mostly consecutive consonants, but that's something to change in the next version of namegen.c. After all, this is only version 0.69 of the code.

P.S. I'm going to give you the link to the namegen.c file on my Dropbox just because I'm that generous. It may or may not be (re)moved at some point in the future so grab it while you still can [or not].

P.P.S. Do NOT (re)distribute my namegen.c file. It may be used for personal use and personal use ONLY. I will keep the rights to that file at all times and it may not be modified without my approval. Kthnxbai :B

P.P.P.S. I'm terribly sorry for the 'DISCLAIMER' joke. Don't take it as offensive [actually do, because it kind of was offensive :]

P.P.P.P.S. Try to make a random name at the length of 42 after compiling and running the code. I double dare you.

No comments:

Post a Comment