CORDIAL MINUET ENSEMBLE

??????

You are not logged in.

#1 2015-03-05 20:35:30

jasonrohrer
Administrator
Registered: 2014-11-20
Posts: 802

195 billion names

I'm in the process of modifying the server code to allow for 3-word random names, should the need arise someday (if we get hundreds of thousands of players).

Okay, so this would take us to 294 million unique names.  But why stop there?  Why not allow 4?  That takes us up to 195 billion unique names.

While they're not quite as evocative as the 2- or 3-word names, they're still interesting.  I can't help but imagine the scene they describe:

conquest singer honeycomb street

grief socialist salutation mountain

graduation promotion settler newspaper

shore soil arrow truck

ghost medallion newspaper nutmeg

Offline

#2 2015-03-05 20:49:30

foreign arches
Member
Registered: 2015-03-01
Posts: 3

Re: 195 billion names

Oh yeah. We have... to go... deeper.

Offline

#3 2015-03-05 21:09:51

jasonrohrer
Administrator
Registered: 2014-11-20
Posts: 802

Re: 195 billion names

Okay, this is in place.  Testing this properly would involve a lot of hassle.  Anyone willing to look at this function and check for mistakes?

ORDER BY RAND() is classic bad practice for large data sets.  This is a small data set, and this function is called once per user created---not very often at all.


function cm_generateRandomName() {
    global $tableNamePrefix;

    $foundUnique = false;
    $tryCount = 0;

    $name = "";

    $numberOfWords = 2;
    
    
    while( ! $foundUnique && $numberOfWords < 5 ) {
        
    
        $query =
            "SELECT GROUP_CONCAT( temp.noun SEPARATOR ' ' ) AS random_name ".
            "FROM ( SELECT noun FROM $tableNamePrefix"."random_nouns ".
            "       ORDER BY RAND() LIMIT $numberOfWords ) AS temp;";

        $result = cm_queryDatabase( $query );

        $name = mysql_result( $result, 0, 0 );

        
        $query = "SELECT COUNT(*) from $tableNamePrefix"."users ".
            "WHERE random_name = '$name';";

        $result = cm_queryDatabase( $query );

        if( 0 == mysql_result( $result, 0, 0 ) ) {
            $foundUnique = true;
            }
        else {
            $tryCount ++;

            if( $tryCount >= 10 ) {
                // can't find unique, try more words
                $numberOfWords ++;
                
                $tryCount = 0;
                }
            }        
        }

    // if we passed the 4-word limit without finding a unique name,
    // give up and use the last 4-word name that we tried.
    
    
    return $name;
    }

Offline

Board footer

Powered by FluxBB