Thread: Name Generator

  1. #1
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    Name Generator

    Back to console for me... at least for a little while. Anyway, does anyone have an open source random name generator i'm thinking of making one. Need some ideas.

  2. #2
    Student drdroid's Avatar
    Join Date
    Feb 2002
    Location
    Montreal, Quebec
    Posts
    669

    ?

    how is that a random name generator? I mean something like:

    A# Something that randomly creates elven names(for dungeons and dragons)

    or

    B# Something that randomly groups first names and last names.

  3. #3
    Evil Member
    Join Date
    Jan 2002
    Posts
    638

    Well

    Usually that is done using just a really long list of possible strings for first anmes, and for last names, and randomly selecting and combining them. You could even use an external text file for this purpose.

    You could, I suppose, come up with an algo to generate a random name based on a set of phonetic elements, but a list is more reliable and usually simpler.

    Perhaps something like:

    Code:
    pseudo...
    
    class nameengine {
    
    public:
    
    nameengine(char* fileName) {open filename, read the integer, .getline that many times and put in firstnames vector, then repeat for last names}
    
    first() {return random element from firstNames}
    
    last() {return random element from lsstNames}
    
    full {return first()+' '+last()}
    
    private:
    
    vector<string> firstNames;
    vector<string> lastNames;
    
    };
    Then in your game just instantiate a few engines like:

    Code:
    nameengine ElvenNames("elfnames.txt");
    
    nameengine HumanNames("mannames.txt");
    
    string thisElfsName = ElvenNames.full();

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. X509v3 digital certificate generator
    By CypherHackz in forum C Programming
    Replies: 1
    Last Post: 03-17-2008, 06:18 AM
  2. Replies: 1
    Last Post: 09-04-2007, 05:31 AM
  3. NAQ: Everything you never wanted to know about CPP
    By evildave in forum C Programming
    Replies: 21
    Last Post: 12-12-2005, 10:56 AM
  4. written command line password generator
    By lepricaun in forum C Programming
    Replies: 15
    Last Post: 08-17-2004, 08:42 PM
  5. .SFV Generator
    By Zewu in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 07-15-2004, 12:00 PM