There’s a method for making “fonetic” random passwords. Well, there are many, but this one is a bit more interesting, because you can produce passwords, which feel right for your language. Of course, whenever there are random elements involved, things might not go quite right, but that’s just part of the fun.
Here, instead of making passwords, we are making names, which sound like they could be names from a certain language, or culture. PHP-code included (sadly, no indents, as the WordPress can’t display them properly). Below, I’m doing names for my Viking set for MtG, but it can be used for fantasy worlds as well, if you can find a good list of names. No offense to the Mongol people, but their names made a very nice basis for goblin names.
This method is based on so called Markov Chains. They are actually pretty simple to use. What you do is form a list of names. From that list, you deduce with what probability do certain characters follow other characters. In this case I’ve chosen to check for single characters following a pair of characters, since this accounts well for common pairs of letters in a language.
Here’s the code for this part:
$file = 'viking-males.txt';
$lines = file($file);
$start = array();
$states = array();
foreach($lines as $line)
{
$line = trim($line);
$temp = strtolower(substr($line, 0, 2));
$start[] = $temp;
for($i = 2; $i < strlen($line); $i++)
{
$temp = strtolower(substr($line, $i-2, 2));
if(isset($states[$temp]))
{
$states[$temp][] = substr($line, $i, 1);
}
else
{
$states[$temp] = array();
$states[$temp][] = substr($line, $i, 1);
}
}
$states[substr($line, strlen($line)-2, 2)][] = 'end';
}
Then, you simply use the statistics produced to form random names by checking the last two characters of your new name and then randomly choosing how to follow them. Note that I've cut out too short or too long names.
include 'markov-statistics.php';
$names = array();
for($i = 0; $i < 25; $i++) { srand(round(microtime() * time() * 1000000)); $name = $start[array_rand($start)]; $temp = $states[$name][array_rand($states[$name])]; while($temp != 'end') { $name.= $temp; $end = substr($name, -2); $temp = $states[$end][array_rand($states[$end])]; } if(strlen($name) > 12 OR strlen($name) < 4) { $i--; } else { $names[] = ucfirst($name); } } asort($names); echo "<pre>"; print_r($names);
Which will produce a list like this:
Array
(
[17] => Arnjorvar
[6] => Asbjorodmarn
[5] => Audgard
[11] => Geir
[20] => Geirmir
[1] => Gudeband
[22] => Haki
[15] => Hanni
[3] => Hard
[8] => Hermund
[18] => Hrand
[4] => Hroddi
[24] => Hæmir
[10] => Jaldulf
[19] => Kardiard
[12] => Kætil
[23] => Lytillf
[13] => Nork
[14] => Ragnfi
[0] => Sleire
[9] => Snolæ
[7] => Steid
[16] => Svalli
[2] => Torgvidi
[21] => Vestend
)
I have no real UI for this, but if you know what you're doing, you'll manage.
The code and a couple of name lists -- note: you'll have to change the name of the file used in the 'markov-statistics.php'-file.