A
A
Anton B2013-11-14 18:21:48
PHP
Anton B, 2013-11-14 18:21:48

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 + ...).
The output is:
Fytiha
Ivazuloh
Ytuma
Uxegon
Uxusec
Jyluvun
Raxuf
Tujeriha
Bemici
Ivinavih
Nicky we get, but they are not beautiful and do not sound.
Maybe there is a ready-made solution in PHP or an algorithm that builds words taking into account phonetics?
Thank you.

Answer the question

In order to leave comments, you need to log in

9 answer(s)
E
Eugene Burmakin, 2013-11-14
@Freika

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.

A
afiskon, 2013-11-14
@afiskon

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.

Y
yparah, 2013-11-14
@yparah

Google to help you.

For example - http://rghost.ru/39359852

A
Andrey Belov, 2013-11-14
@Andrey_Belov

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.

C
charon, 2013-11-14
@charon

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.

D
dginz, 2013-11-22
@dginz

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.

A
AlexBin, 2015-02-20
@AlexBin

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.

K
kuzma95, 2019-11-16
@kuzma95

There is an api generator that works based on real words https://rustxt.ru/generator-nick-name

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question