Answer the question
In order to leave comments, you need to log in
Prompt nickname generator (ready-made script or algorithm)
Task: to implement a generator of beautiful nicknames for an online game.
Now this problem is solved like this:
function nickname_gen() {
$symbol_arr = array('aeiouy', 'bcdfghjklmnpqrstvwxz');
$length = mt_rand(5, 8);
$return = array();
foreach ($symbol_arr as $k => $v)
$symbol_arr[$k] = str_split($v);
for ($i = 0; $i < $length; $i++) {
while (true) {
$symbol_x = mt_rand(0, sizeof($symbol_arr) - 1);
$symbol_y = mt_rand(0, sizeof($symbol_arr[$symbol_x]) - 1);
if ($i > 0 && in_array($return[$i - 1], $symbol_arr[$symbol_x]))
continue;
$return[] = $symbol_arr[$symbol_x][$symbol_y];
break;
}
}
$return = ucfirst(implode('', $return));
return $return;
}
We divide all the letters of the Latin alphabet into vowels and consonants, and then we collect a word of the required length from them (vowel + consonant + vowel + ...). Fytiha
Ivazuloh
Ytuma
Uxegon
Uxusec
Jyluvun
Raxuf
Tujeriha
Bemici
Ivinavih
Nicky we get, but they are not beautiful and do not sound. Answer the question
In order to leave comments, you need to log in
My nickname generator generates nicknames based on mixed syllables. The array contains syllables and the algorithm is as follows: random prefix syllable + random middle syllable + random ending syllable. The problem is that collecting a database of syllables is very muddy.
Often generated by transliterating the user's first or last name and adding the digits of the year of birth.
Well, or you can manually come up with a dozen or two "beautiful" nicknames, then break them into syllables and generate from them. pwgen will help here. For example, it was:
zeratog rootak erlanger
We break it down and get:
zetak rootanger
etc.
In my opinion, quite tolerable nicknames, by the way. One of the options for refinement - maybe it's worth trying to take into account the frequency of letters in ordinary English texts ( http://en.wikipedia.org/wiki/Letter_frequency ). For example, you have a lot of "y" and "x" in your nicknames, which are usually not very frequent and can cause a feeling of dissonance. That is, from vowels, you should use "e", "a", "o", etc. more often. If you can find the statistics of English syllables, then you can try to use it too.
collect a large selection of different nicknames, statistically calculate the probability of different 2-3 letter combinations in them, select the most probable ones and just randomly combine them in the generator.
I once wrote an algorithm for generating euphonious easy-to-generate passwords. To do this, I simply calculated with what probability one letter will be followed by another, analyzing, for example, "The Lord of the Rings", then I simply took a random first letter and added the next one to it, taking into account the probability, and so on, we got passwords like (take in as length 12 letters):
leeditedildo
rsiecayweeyo
qugendsivour
yandaskithee
kehefothevou
Here is the C code: https://github.com/ginz/getpass
It can be easily rewritten/adapted to PHP.
I also wrote a generator, it gives out these words.
Tristrag Mansel Oricated Nalere Stinat Ratemath Cesele Tralis Geselica Marretitit Terrec Caritarr Kintatim Derage Cletiane Acedianc Aricatem Inaton Latinate Pinintia Strinese Gerissente Visermar Ressit Vellicte Hantemat Ratter Enetie Lerrelat.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question